Skip to content

VIH-11091 - replace Faker.NetCore with Bogus #2351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions VideoWeb/VideoWeb.AcceptanceTests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
"Selenium.WebDriver": "3.10.0"
}
},
"Faker.NETCore": {
"type": "Direct",
"requested": "[1.0.2, )",
"resolved": "1.0.2",
"contentHash": "teRWZFwtBSuMRo2jxB4/DfCo3nprjMtjb7tjBfhrnz+BPhQMivW9cVo06kLr4GAJjrCOvCNQ2sJckRwGvMmK0Q==",
"dependencies": {
"NETStandard.Library": "1.6.0"
}
},
"FluentAssertions": {
"type": "Direct",
"requested": "[5.10.3, )",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Bogus;
using FizzWare.NBuilder;
using VideoWeb.Common.Models;

Expand All @@ -9,6 +10,7 @@ namespace VideoWeb.UnitTests.Builders
public class ConferenceCacheModelBuilder
{
private readonly Conference _conference;
private static readonly Faker Faker = new();

public ConferenceCacheModelBuilder()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Threading;
using System.Threading.Tasks;
using Autofac.Extras.Moq;
using Bogus;
using BookingsApi.Client;
using BookingsApi.Contract.V2.Requests;
using BookingsApi.Contract.V2.Responses;
using Faker;
using FizzWare.NBuilder;
using FluentAssertions;
using Microsoft.AspNetCore.Http;
Expand All @@ -34,6 +34,8 @@ public class GetConferencesForVhOfficerTests
private AutoMock _mocker;
private ConferencesController _controller;

private static readonly Faker Faker = new();

[SetUp]
public void Setup()
{
Expand Down Expand Up @@ -157,7 +159,7 @@ private static (List<ConferenceDetailsResponse> conferences, List<HearingDetails
{
var participants = Builder<ParticipantResponse>.CreateListOfSize(4)
.All()
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.With(x => x.LinkedParticipants = new List<LinkedParticipantResponse>())
.TheFirst(1).With(x => x.UserRole = UserRole.Judge)
.TheRest().With(x => x.UserRole = UserRole.Individual).Build().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
using VideoWeb.Controllers;
using Autofac.Extras.Moq;
using VideoWeb.Common;
using Bogus;

namespace VideoWeb.UnitTests.Controllers.ConferenceManagement
{
public abstract class ConferenceManagementControllerTestBase
{
protected AutoMock _mocker;
protected Conference TestConference;
private static readonly Faker Faker = new();

protected ConferenceManagementController SetupControllerWithClaims(ClaimsPrincipal claimsPrincipal)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
using System.Threading;
using System.Threading.Tasks;
using Autofac.Extras.Moq;
using BookingsApi.Client;
using Bogus;
using BookingsApi.Contract.V1.Responses;
using Faker;
using FizzWare.NBuilder;
using FluentAssertions;
using Microsoft.AspNetCore.Http;
Expand All @@ -20,15 +19,14 @@
using VideoWeb.Common.Models;
using VideoWeb.Contract.Responses;
using VideoWeb.UnitTests.Builders;
using LinkedParticipantResponse = VideoApi.Contract.Responses.LinkedParticipantResponse;
using ParticipantResponse = VideoApi.Contract.Responses.ParticipantResponse;

namespace VideoWeb.UnitTests.Controllers.EndOfDayController;

public class GetActiveConferencesTests
{
private AutoMock _mocker;
private VideoWeb.Controllers.EndOfDayController _sut;
private static readonly Faker Faker = new();

[SetUp]
public void Setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Faker;
using FizzWare.NBuilder;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -15,11 +14,14 @@
using VideoApi.Client;
using VideoApi.Contract.Responses;
using VideoWeb.Common;
using Bogus;

namespace VideoWeb.UnitTests.Controllers.InstantMessageController;

public class GetUnreadMessagesForParticipantsTests : InstantMessageControllerTestBase
{
private static readonly Faker Faker = new();

[Test]
public async Task Should_return_exception()
{
Expand Down Expand Up @@ -117,7 +119,7 @@ private static Conference InitConference()
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Id = Guid.NewGuid())
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheNext(1).With(x => x.Role = Role.Representative)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Faker;
using Bogus;
using FizzWare.NBuilder;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -20,6 +20,8 @@ namespace VideoWeb.UnitTests.Controllers.InstantMessageController;

public class GetUnreadMessagesForVideoOfficerTests : InstantMessageControllerTestBase
{
private static readonly Faker Faker = new();

[Test]
public async Task Should_return_exception()
{
Expand Down Expand Up @@ -79,7 +81,7 @@ private static Conference InitConference()
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Id = Guid.NewGuid())
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
using ParticipantResponse = VideoApi.Contract.Responses.ParticipantResponse;
using VideoWeb.EventHub.Handlers.Core;
using VideoWeb.Helpers.Interfaces;
using Bogus;

namespace VideoWeb.UnitTests.Controllers.ParticipantController;

public class DeleteParticipantTests
{
private AutoMock _mocker;
private ParticipantsController _sut;
private static readonly Faker Faker = new();

[SetUp]
public void Setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using VideoWeb.Common;
using VideoWeb.UnitTests.Builders;
using EventComponentHelper = VideoWeb.UnitTests.Builders.EventComponentHelper;
using Bogus;

namespace VideoWeb.UnitTests.EventHandlers;

Expand All @@ -27,6 +28,8 @@ public abstract class EventHandlerTestBase
protected Conference TestConference { get; set; }

private EventComponentHelper _eventComponentHelper;

private static readonly Faker Faker = new();

[SetUp]
public void Setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using VideoWeb.EventHub.Models;
using VideoWeb.Helpers;
using VideoWeb.UnitTests.Builders;
using Bogus;

namespace VideoWeb.UnitTests.Helpers;

Expand All @@ -21,6 +22,7 @@ public class EndpointsUpdatedEventNotifierTests
private EndpointsUpdatedEventNotifier _notifier;
private Conference _conference;
private EventComponentHelper _eventHelper;
private static readonly Faker Faker = new();

[SetUp]
public void SetUp()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Bogus;
using FizzWare.NBuilder;
using Microsoft.AspNetCore.SignalR;
using Moq;
Expand All @@ -17,6 +18,7 @@ public class HearingCancelledEventNotifierTests
private HearingCancelledEventNotifier _notifier;
private Conference _conference;
private EventComponentHelper _eventHelper;
private static readonly Faker Faker = new();

[SetUp]
public void SetUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using VideoWeb.EventHub.Hub;
using VideoWeb.Helpers;
using VideoWeb.UnitTests.Builders;
using Bogus;

namespace VideoWeb.UnitTests.Helpers
{
Expand All @@ -19,6 +20,9 @@ public class HearingDetailsUpdatedEventNotifierTests
private Conference _conference;
private EventComponentHelper _eventHelper;

private static readonly Faker Faker = new();


[SetUp]
public void SetUp()
{
Expand Down
2 changes: 2 additions & 0 deletions VideoWeb/VideoWeb.UnitTests/Hub/EventHubBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Bogus;
using FizzWare.NBuilder;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -34,6 +35,7 @@ public abstract class EventHubBaseTests
protected Mock<IHeartbeatRequestMapper> HeartbeatMapper;
protected Mock<IConferenceVideoControlStatusService> ConferenceVideoControlStatusService;
protected Mock<IConferenceManagementService> ConferenceManagementServiceMock;
private static readonly Faker Faker = new();

[SetUp]
public void Setup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
using RoomType = VideoApi.Contract.Enums.RoomType;
using Supplier = VideoWeb.Common.Enums.Supplier;
using TelephoneParticipantResponse = VideoApi.Contract.Responses.TelephoneParticipantResponse;
using Bogus;

namespace VideoWeb.UnitTests.Mappings;

public class ConferenceCacheMapperTests
{
private static readonly Faker Faker = new();

[Test]
public void Should_map_all_properties()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Faker;
using Bogus;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
Expand All @@ -13,12 +13,14 @@ namespace VideoWeb.UnitTests.Mappings;

public class UnreadAdminMessageResponseMapperTests
{
private static readonly Faker Faker = new();

[Test]
public void Should_map_and_count_number_of_messages_since_vho_message()
{
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();

Expand Down Expand Up @@ -57,7 +59,7 @@ public void Should_map_and_return_total_message_count_when_vho_has_not_answered(
{
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();

Expand Down Expand Up @@ -90,7 +92,7 @@ public void should_map_total_message_count_when_there_is_no_chat_history()
{
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Faker;
using Bogus;
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
Expand All @@ -13,12 +13,14 @@ namespace VideoWeb.UnitTests.Mappings;

public class UnreadInstantMessageConferenceCountResponseToConferenceMapperTests
{
private static readonly Faker Faker = new();

[Test]
public void Should_map_and_count_number_of_messages_since_vho_message()
{
var participants = Builder<Participant>.CreateListOfSize(4)
.All()
.With(x => x.Username = Internet.Email())
.With(x => x.Username = Faker.Internet.Email())
.TheFirst(1).With(x => x.Role = Role.Judge)
.TheRest().With(x => x.Role = Role.Individual).Build().ToList();

Expand Down
2 changes: 1 addition & 1 deletion VideoWeb/VideoWeb.UnitTests/VideoWeb.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extras.Moq" Version="6.1.1" />
<PackageReference Include="Bogus" Version="35.6.1" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Faker.NETCore" Version="1.0.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
<PackageReference Include="Microsoft.TestPlatform" Version="17.9.0" />
Expand Down
Loading
Loading