public SetMovementRejectedHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); movementId = Guid.NewGuid(); rejectDate = SystemTime.UtcNow; rejectMovement = A.Fake <IRejectMovement>(); movementRepository = A.Fake <IMovementRepository>(); fileRepository = A.Fake <IFileRepository>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); var notificationRepository = A.Fake <INotificationApplicationRepository>(); var nameGenerator = new MovementFileNameGenerator(notificationRepository); var certificateFactory = new CertificateFactory(); var userContext = A.Fake <IUserContext>(); A.CallTo(() => notificationRepository.GetById(notificationId)) .Returns(new TestableNotificationApplication() { NotificationNumber = NotificatioNumber }); A.CallTo(() => fileRepository.Store(A <File> .Ignored)).Returns(Guid.NewGuid()); A.CallTo(() => userContext.UserId).Returns(TestIwsContext.UserId); handler = new SetMovementRejectedHandler(rejectMovement, movementRepository, context, nameGenerator, certificateFactory, fileRepository, movementAuditRepository, userContext); }
public GetTransitStateWithEntryOrExitDataHandlerTests() { mapper = A.Fake <IMapper>(); transportRouteRepository = A.Fake <ITransportRouteRepository>(); var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); context.EntryOrExitPoints.AddRange(new List <EntryOrExitPoint>(EntryExitPoints) { new TestableEntryOrExitPoint() { Country = new TestableCountry() { Id = countryId } }, new TestableEntryOrExitPoint() { Country = new TestableCountry() { Id = countryId } } }); A.CallTo(() => mapper.Map <EntryOrExitPointData>(A <EntryOrExitPoint> .Ignored)) .Returns(new EntryOrExitPointData() { CountryId = countryId, Name = AnyString }); handler = new GetTransitStateWithEntryOrExitDataHandler(context, mapper, transportRouteRepository); }
public SetMultipleMovementFileIdHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); fileId = Guid.NewGuid(); var userId = TestIwsContext.UserId; movementRepository = A.Fake <IMovementRepository>(); notificationRepository = A.Fake <INotificationApplicationRepository>(); fileRepository = A.Fake <IFileRepository>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); var userContext = A.Fake <IUserContext>(); A.CallTo(() => notificationRepository.GetById(notificationId)) .Returns(new TestableNotificationApplication() { NotificationNumber = NotificatioNumber }); A.CallTo(() => fileRepository.Store(A <File> .Ignored)).Returns(fileId); A.CallTo(() => userContext.UserId).Returns(userId); handler = new SetMultipleMovementFileIdHandler(context, movementRepository, notificationRepository, fileRepository, movementAuditRepository, userContext); }
public UpdateTransitStateEntryOrExitHandlerTests() { transportRouteRepository = A.Fake <ITransportRouteRepository>(); var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); context.EntryOrExitPoints.AddRange(new List <EntryOrExitPoint>(EntryExitPoints) { new TestableEntryOrExitPoint() { Id = entryPointId, Country = new TestableCountry() { Id = countryId } }, new TestableEntryOrExitPoint() { Id = exitPointId, Country = new TestableCountry() { Id = countryId } } }); handler = new UpdateTransitStateEntryOrExitHandler(context, transportRouteRepository); }
public SaveMovementCompletedReceiptHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); movementId = Guid.NewGuid(); fileId = Guid.NewGuid(); var userContext = A.Fake <IUserContext>(); movementRepository = A.Fake <IMovementRepository>(); fileRepository = A.Fake <IFileRepository>(); notificationRepository = A.Fake <INotificationApplicationRepository>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); A.CallTo(() => notificationRepository.GetById(notificationId)) .Returns(new TestableNotificationApplication() { NotificationNumber = NotificationNumber }); A.CallTo(() => fileRepository.Store(A <File> .Ignored)).Returns(fileId); var nameGenerator = new CertificateOfRecoveryNameGenerator(notificationRepository); var certificateFactory = new CertificateFactory(); handler = new SaveMovementCompletedReceiptHandler(context, fileRepository, movementRepository, certificateFactory, nameGenerator, userContext, notificationRepository, movementAuditRepository); }
public SetMovementPartialRejectedHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); movementId = Guid.NewGuid(); rejectDate = SystemTime.UtcNow; wasteDate = SystemTime.UtcNow; partialRejectionMovement = A.Fake <IPartialRejectionMovement>(); movementRepository = A.Fake <IMovementRepository>(); var notificationRepository = A.Fake <INotificationApplicationRepository>(); var userContext = A.Fake <IUserContext>(); A.CallTo(() => notificationRepository.GetById(notificationId)) .Returns(new TestableNotificationApplication() { NotificationNumber = NotificatioNumber }); A.CallTo(() => userContext.UserId).Returns(TestIwsContext.UserId); handler = new RecordPartialRejectionInternalHandler(partialRejectionMovement, context); }
public DeleteWasteRecoveryWhenProviderChangesToImporterTests() { context = new TestIwsContext(); recoveryRepository = A.Fake <IWasteRecoveryRepository>(); disposalRepository = A.Fake <IWasteDisposalRepository>(); handler = new DeleteWasteRecoveryWhenProviderChangesToImporter(context, recoveryRepository, disposalRepository); }
public DeleteWasteRecoveryWhenProviderChangesToImporterTests() { context = new TestIwsContext(); recoveryRepository = A.Fake<IWasteRecoveryRepository>(); disposalRepository = A.Fake<IWasteDisposalRepository>(); handler = new DeleteWasteRecoveryWhenProviderChangesToImporter(context, recoveryRepository, disposalRepository); }
public AddressMapTests() { var context = new TestIwsContext(); addressMap = new AddressMap(context); context.Countries.Add(TestableCountry.UnitedKingdom); context.Countries.Add(TestableCountry.Switzerland); context.Countries.Add(TestableCountry.France); }
public GetCompetentAuthoritiesAndEntryPointsByCountryIdHandlerTests() { entryOrExitPointRepository = A.Fake <IEntryOrExitPointRepository>(); intraCountryExportAllowedRepository = A.Fake <IIntraCountryExportAllowedRepository>(); unitedKingdomCompetentAuthorityRepository = A.Fake <IUnitedKingdomCompetentAuthorityRepository>(); var iwsContext = new TestIwsContext(); var countryWithData = CountryFactory.Create(countryWithDataId); var unitedKingdomCountry = CountryFactory.Create(unitedKingdomCountryId); var countryWithNoData = CountryFactory.Create(countryWithNoDataId); competentAuthorities = new[] { CompetentAuthorityFactory.Create(new Guid("67D2B3B5-298A-4BB5-901C-0C0C80097242"), unitedKingdomCountry), CompetentAuthorityFactory.Create(new Guid("5E7CA40F-D7B5-49C3-8850-694D36D52C94"), countryWithData), CompetentAuthorityFactory.Create(new Guid("DFD98B0D-F255-4BA0-96A5-527DE9F973E3"), countryWithData) }; A.CallTo(() => unitedKingdomCompetentAuthorityRepository.GetAll()).Returns(new[] { new TestableUnitedKingdomCompetentAuthority(1, competentAuthorities[0], "something", null) }); var competentAuthorityMapper = new CompetentAuthorityMap(); var entryOrExitPointMapper = new EntryOrExitPointMap(); A.CallTo(() => entryOrExitPointRepository.GetForCountry(countryWithDataId)).Returns(new[] { EntryOrExitPointFactory.Create(new Guid("FC012C3E-4252-4D62-A8A2-D46DE0FA93B9"), countryWithData), EntryOrExitPointFactory.Create(new Guid("9699CC16-6EF1-4889-9598-F4B0511A2038"), countryWithData) }); A.CallTo(() => intraCountryExportAllowedRepository.GetImportCompetentAuthorities(UKCompetentAuthority.England)).Returns(new[] { new TestableIntraCountryExportAllowed { ExportCompetentAuthority = UKCompetentAuthority.England, ImportCompetentAuthorityId = competentAuthorities[1].Id } }); repository = A.Fake <ICompetentAuthorityRepository>(); A.CallTo(() => repository.GetCompetentAuthorities(countryWithDataId)).Returns(competentAuthorities); ids = new Guid[] { competentAuthorities[1].Id }; A.CallTo(repository).Where(call => call.Method.Name == "GetByIds") .WithReturnType <CompetentAuthority[]>() .Returns(competentAuthorities); handler = new GetCompetentAuthoritiesAndEntryPointsByCountryIdHandler(entryOrExitPointMapper, competentAuthorityMapper, repository, entryOrExitPointRepository, intraCountryExportAllowedRepository, iwsContext, unitedKingdomCompetentAuthorityRepository); }
public SetOperationCodesHandlerTests() { this.context = new TestIwsContext(); this.notificationRepository = A.Fake <INotificationApplicationRepository>(); A.CallTo(() => notificationRepository.GetById(A <Guid> .Ignored)).Returns(GetFakeApplication()); this.message = A.Fake <SetOperationCodes>(); this.handler = new SetOperationCodesHandler(this.context, this.notificationRepository); }
public SetNotificationReceivedDateHandlerTests() { context = new TestIwsContext(); assessment = new NotificationAssessment(notificationId); ObjectInstantiator<NotificationAssessment>.SetProperty(x => x.Status, NotificationStatus.Submitted, assessment); context.NotificationAssessments.Add(assessment); handler = new SetNotificationReceivedDateHandler(context); message = new SetNotificationReceivedDate(notificationId, notificationReceivedDate); }
public SetNotificationReceivedDateHandlerTests() { context = new TestIwsContext(); assessment = new NotificationAssessment(notificationId); ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.Submitted, assessment); context.NotificationAssessments.Add(assessment); handler = new SetNotificationReceivedDateHandler(context); message = new SetNotificationReceivedDate(notificationId, notificationReceivedDate); }
public SetCommencedDateHandlerTests() { context = new TestIwsContext(); var assessment = new NotificationAssessment(notificationId); ObjectInstantiator<NotificationAssessment>.SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment); ObjectInstantiator<NotificationDates>.SetProperty(x => x.PaymentReceivedDate, receivedDate, assessment.Dates); context.NotificationAssessments.Add(assessment); message = new SetCommencedDate(notificationId, commencementDate, "Officer"); handler = new SetCommencedDateHandler(context); }
public RefuseFinancialGuaranteeHandlerTests() { context = new TestIwsContext(); repository = A.Fake<IFinancialGuaranteeRepository>(); var financialGuaranteeCollection = new TestFinancialGuaranteeCollection(ApplicationCompletedId); financialGuarantee = new TestFinancialGuarantee(FinancialGuaranteeId); financialGuaranteeCollection.AddExistingFinancialGuarantee(financialGuarantee); A.CallTo(() => repository.GetByNotificationId(ApplicationCompletedId)).Returns(financialGuaranteeCollection); handler = new RefuseFinancialGuaranteeHandler(repository, context); }
public RefuseFinancialGuaranteeHandlerTests() { context = new TestIwsContext(); repository = A.Fake <IFinancialGuaranteeRepository>(); var financialGuaranteeCollection = new TestFinancialGuaranteeCollection(ApplicationCompletedId); financialGuarantee = new TestFinancialGuarantee(FinancialGuaranteeId); financialGuaranteeCollection.AddExistingFinancialGuarantee(financialGuarantee); A.CallTo(() => repository.GetByNotificationId(ApplicationCompletedId)).Returns(financialGuaranteeCollection); handler = new RefuseFinancialGuaranteeHandler(repository, context); }
public SetCommencedDateHandlerTests() { context = new TestIwsContext(); var assessment = new NotificationAssessment(notificationId); ObjectInstantiator <NotificationAssessment> .SetProperty(x => x.Status, NotificationStatus.NotificationReceived, assessment); ObjectInstantiator <NotificationDates> .SetProperty(x => x.PaymentReceivedDate, receivedDate, assessment.Dates); context.NotificationAssessments.Add(assessment); message = new SetCommencedDate(notificationId, commencementDate, "Officer"); handler = new SetCommencedDateHandler(context); }
public SetWasteRecoveryProviderHandlerTests() { context = new TestIwsContext(); repository = A.Fake <INotificationApplicationRepository>(); var notification = new TestableNotificationApplication { Id = NotificationId }; context.NotificationApplications.Add(notification); A.CallTo(() => repository.GetById(NotificationId)).Returns(notification); handler = new SetWasteRecoveryProviderHandler(repository, context); }
public CreateMovementCarriersHandlerTests() { SystemTime.Freeze(new DateTime(2019, 1, 1)); movementIds[0] = new Guid("AF1839A1-DA40-430B-9DFE-D79194175DFD"); var carrierRepository = A.Fake <ICarrierRepository>(); context = new TestIwsContext(); handler = new CreateMovementCarriersHandler(context, repository, carrierRepository); request = new CreateMovementCarriers(notificationId, movementIds, new Dictionary <int, Guid>() { { 1, CarrierId } }); }
public SetWasteRecoveryProviderHandlerTests() { context = new TestIwsContext(); repository = A.Fake<INotificationApplicationRepository>(); var notification = new TestableNotificationApplication { Id = NotificationId }; context.NotificationApplications.Add(notification); A.CallTo(() => repository.GetById(NotificationId)).Returns(notification); handler = new SetWasteRecoveryProviderHandler(repository, context); }
public async Task FindMatchingOrganisationsHandler_WithLtdAndLimitedCompany_TwoMatches() { var context = new TestIwsContext(); context.Organisations.AddRange(new[] { GetOrganisationWithName("SFW Ltd"), GetOrganisationWithName("SFW Limited") }); var handler = new FindMatchingOrganisationsHandler(context); var strings = await handler.HandleAsync(new FindMatchingOrganisations("sfw")); Assert.Equal(2, strings.Count); }
public async Task FindMatchingOrganisationsHandler_AllDataMatches_ReturnedStringsMatchInputDataWithCase() { var names = new[] { "Environment Agency", "Environemnt Agincy" }; var data = names.Select(GetOrganisationWithName).ToArray(); var context = new TestIwsContext(); context.Organisations.AddRange(data); var handler = new FindMatchingOrganisationsHandler(context); var results = await handler.HandleAsync(new FindMatchingOrganisations("Environment Agency")); Assert.Equal(names, results.Select(r => r.Name)); }
public async Task FindMatchingOrganisationsHandler_SearchTermContainsThe_ReturnsMatchingResults() { var context = new TestIwsContext(); context.Organisations.AddRange(new[] { GetOrganisationWithName("Environment Agency"), GetOrganisationWithName("Enivronent Agency") }); var handler = new FindMatchingOrganisationsHandler(context); var results = await handler.HandleAsync(new FindMatchingOrganisations("THe environment agency")); Assert.Equal(2, results.Count); }
public SearchExportNotificationsHandlerTests() { var applications = GetNotificationApplications(); var assessments = GetNotificationAssessments(); var context = new TestIwsContext(); var userContext = A.Fake <IUserContext>(); context.NotificationApplications.AddRange(applications); context.Exporters.AddRange(GetExporters()); context.NotificationAssessments.AddRange(assessments); context.InternalUsers.AddRange(GetUsers()); A.CallTo(() => userContext.UserId).Returns(new Guid("ac795e26-1563-4833-b8f9-0529eb9e66ae")); handler = new SearchExportNotificationsHandler(context, userContext); }
public SetMovementAcceptedHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); movementId = Guid.NewGuid(); movementRepository = A.Fake <IMovementRepository>(); var userContext = A.Fake <IUserContext>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); handler = new SetMovementAcceptedHandler(movementRepository, context, userContext, movementAuditRepository); }
public SearchExportNotificationsHandlerTests() { var applications = GetNotificationApplications(); var assessments = GetNotificationAssessments(); var context = new TestIwsContext(); var userContext = A.Fake<IUserContext>(); context.NotificationApplications.AddRange(applications); context.Exporters.AddRange(GetExporters()); context.NotificationAssessments.AddRange(assessments); context.InternalUsers.AddRange(GetUsers()); A.CallTo(() => userContext.UserId).Returns(new Guid("ac795e26-1563-4833-b8f9-0529eb9e66ae")); handler = new SearchExportNotificationsHandler(context, userContext); }
public SetBaselOecdCodeForNotificationHandlerTests() { context = new TestIwsContext(new TestUserContext(Guid.Empty)); handler = new SetBaselOecdCodeForNotificationHandler(context); codes = new List<WasteCodeInfo>(); context.NotificationApplications.Add(new TestableNotificationApplication { Id = NotificationId, WasteCodes = codes, UserId = Guid.Empty }); context.WasteCodes.AddRange(wasteCodes); }
public EditYCodesHandlerTests() { context = new TestIwsContext(new TestUserContext(Guid.Empty)); handler = new EditYCodesHandler(context); codes = new List <WasteCodeInfo>(); context.NotificationApplications.Add(new TestableNotificationApplication { Id = NotificationId, WasteCodes = codes, UserId = Guid.Empty }); context.WasteCodes.AddRange(wasteCodes); }
public ApproveFinancialGuaranteeHandlerTests() { context = new TestIwsContext(); repository = A.Fake<IFinancialGuaranteeRepository>(); var financialGuaranteeCollection = new TestFinancialGuaranteeCollection(ApplicationCompletedId); financialGuarantee = new TestFinancialGuarantee(FinancialGuaranteeId); financialGuarantee.SetStatus(FinancialGuaranteeStatus.ApplicationComplete); financialGuarantee.CompletedDate = FirstDate; financialGuaranteeCollection.AddExistingFinancialGuarantee(financialGuarantee); A.CallTo(() => repository.GetByNotificationId(ApplicationCompletedId)).Returns(financialGuaranteeCollection); var approval = new FinancialGuaranteeApproval(repository); handler = new ApproveFinancialGuaranteeHandler(approval, context); }
public AddCarrierHandlerTests() { notificationId = Guid.NewGuid(); countryId = Guid.NewGuid(); countryRepository = A.Fake <ICountryRepository>(); repository = A.Fake <ICarrierRepository>(); var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); var carrierCollection = new CarrierCollection(notificationId); A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(carrierCollection); handler = new AddCarrierHandler(context, repository, countryRepository); }
public UpdateMovementDateHandlerTests() { var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); notificationId = Guid.NewGuid(); var validator = A.Fake <IUpdatedMovementDateValidator>(); repository = A.Fake <IMovementRepository>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); var userContext = A.Fake <IUserContext>(); A.CallTo(() => userContext.UserId).Returns(TestIwsContext.UserId); handler = new UpdateMovementDateHandler(repository, validator, context, movementAuditRepository, userContext); }
public ApproveFinancialGuaranteeHandlerTests() { context = new TestIwsContext(); repository = A.Fake <IFinancialGuaranteeRepository>(); var financialGuaranteeCollection = new TestFinancialGuaranteeCollection(ApplicationCompletedId); financialGuarantee = new TestFinancialGuarantee(FinancialGuaranteeId); financialGuarantee.SetStatus(FinancialGuaranteeStatus.ApplicationComplete); financialGuarantee.CompletedDate = FirstDate; financialGuaranteeCollection.AddExistingFinancialGuarantee(financialGuarantee); A.CallTo(() => repository.GetByNotificationId(ApplicationCompletedId)).Returns(financialGuaranteeCollection); var approval = new FinancialGuaranteeApproval(repository); handler = new ApproveFinancialGuaranteeHandler(approval, context); }
public async Task FindMatchingOrganisationsHandler_WithLtdCompany_OneMatches() { var context = new TestIwsContext(); context.Organisations.AddRange(new[] { GetOrganisationWithName("SFW Ltd"), GetOrganisationWithName("swf"), GetOrganisationWithName("mfw"), GetOrganisationWithName("mfi Kitchens and Showrooms Ltd"), GetOrganisationWithName("SEPA England"), GetOrganisationWithName("Tesco Recycling") }); var handler = new FindMatchingOrganisationsHandler(context); var strings = await handler.HandleAsync(new FindMatchingOrganisations("sfw")); Assert.Equal(1, strings.Count); }
public CancelMovementsHandlerTests() { notificationId = Guid.NewGuid(); var userId = TestIwsContext.UserId; var context = new TestIwsContext(); context.Users.Add(UserFactory.Create(TestIwsContext.UserId, AnyString, AnyString, AnyString, AnyString)); repository = A.Fake <IMovementRepository>(); movementAuditRepository = A.Fake <IMovementAuditRepository>(); var userContext = A.Fake <IUserContext>(); capturedMovementFactory = A.Fake <ICapturedMovementFactory>(); A.CallTo(() => userContext.UserId).Returns(userId); handler = new CancelMovementsHandler(context, repository, movementAuditRepository, userContext, capturedMovementFactory); }
public RecordMovementStatusChangeTest() { notificationId = new Guid("1BDB59A9-349E-43E2-9D81-51955FDBF735"); userId = TestIwsContext.UserId; //TODO: create ObjectInstantator<T>.CreateInstance(params) method... var flags = BindingFlags.NonPublic | BindingFlags.Instance; var culture = CultureInfo.InvariantCulture; var parameters = new object[] { 1, notificationId, new DateTime(2015, 1, 1), userId }; movement = (Movement)Activator.CreateInstance( typeof(Movement), flags, null, parameters, culture); context = new TestIwsContext(); context.Users.Add(UserFactory.Create(userId, AnyString, AnyString, AnyString, AnyString)); var userContext = new TestUserContext(userId); handler = new RecordMovementStatusChange(context, userContext); receivedEvent = new MovementStatusChangeEvent(movement, MovementStatus.Submitted); }
public SearchImportNotificationsHandlerTests() { var applications = GetImportNotifications(); var assessments = GetNotificationAssessments(); var impNotificationContext = new TestImportNotificationContext(); var iwsContext = new TestIwsContext(); var userContext = A.Fake <IUserContext>(); var testMapper = new TestMapper(); testMapper.AddMapper(new SearchResultMap()); impNotificationContext.ImportNotifications.AddRange(applications); impNotificationContext.Importers.AddRange(GetImporters()); impNotificationContext.ImportNotificationAssessments.AddRange(assessments); iwsContext.InternalUsers.AddRange(GetUsers()); A.CallTo(() => userContext.UserId).Returns(new Guid("ac795e26-1563-4833-b8f9-0529eb9e66ae")); importNotificationSearchRepository = new ImportNotificationSearchRepository(iwsContext, impNotificationContext, userContext); handler = new SearchImportNotificationsHandler(importNotificationSearchRepository, testMapper); }
public async Task FindMatchingOrganisationsHandler_AllDataMatches_ReturnsDataOrderedByEditDistance() { var searchTerm = "bee keepers"; var namesWithDistances = new[] { new KeyValuePair <string, int>("THE Bee Keepers Limited", 0), new KeyValuePair <string, int>("Bee Keeperes", 1), new KeyValuePair <string, int>("BeeKeeprs", 2) }; var organisations = namesWithDistances.Select(n => GetOrganisationWithName(n.Key)).ToArray(); var context = new TestIwsContext(); context.Organisations.AddRange(organisations); var handler = new FindMatchingOrganisationsHandler(context); var results = await handler.HandleAsync(new FindMatchingOrganisations(searchTerm)); Assert.Equal(namesWithDistances.OrderBy(n => n.Value).Select(n => n.Key), results.Select(r => r.Name)); }
public SaveWasteRecoveryHandlerTests() { context = new TestIwsContext(); repository = A.Fake<IWasteRecoveryRepository>(); handler = new SaveWasteRecoveryHandler(repository, context); }
public CreateInternalUserHandlerTests() { context = new TestIwsContext(); handler = new CreateInternalUserHandler(context); }
public DeleteWasteDisposalWhenRecoverablePercentageChangedToMaxTests() { context = new TestIwsContext(); repository = A.Fake<IWasteDisposalRepository>(); handler = new DeleteWasteDisposalWhenRecoverablePercentageChangedToMax(context, repository); }
public SaveWasteRecoveryHandlerTests() { context = new TestIwsContext(); repository = A.Fake <IWasteRecoveryRepository>(); handler = new SaveWasteRecoveryHandler(repository, context); }
public async Task FindMatchingOrganisationsHandler_DataContainsThe_ReturnsMatchingResults() { var context = new TestIwsContext(); context.Organisations.AddRange(new[] { GetOrganisationWithName("THE Environemnt Agency"), GetOrganisationWithName("THE Environemnt Agency"), GetOrganisationWithName("Environment Agency") }); var handler = new FindMatchingOrganisationsHandler(context); var results = await handler.HandleAsync(new FindMatchingOrganisations("Environment Agency")); Assert.Equal(3, results.Count); }
public async Task FindMatchingOrganisationsHandler_AllDataMatches_ReturnsDataOrderedByEditDistance() { var searchTerm = "bee keepers"; var namesWithDistances = new[] { new KeyValuePair<string, int>("THE Bee Keepers Limited", 0), new KeyValuePair<string, int>("Bee Keeperes", 1), new KeyValuePair<string, int>("BeeKeeprs", 2) }; var organisations = namesWithDistances.Select(n => GetOrganisationWithName(n.Key)).ToArray(); var context = new TestIwsContext(); context.Organisations.AddRange(organisations); var handler = new FindMatchingOrganisationsHandler(context); var results = await handler.HandleAsync(new FindMatchingOrganisations(searchTerm)); Assert.Equal(namesWithDistances.OrderBy(n => n.Value).Select(n => n.Key), results.Select(r => r.Name)); }