public NotificationTransportRouteTests() { this.transportRoute = new TransportRoute(Guid.Empty); guids = new List <Guid> { new Guid("D8DB53F9-D3CB-498D-B044-7A67B94EE4E4"), new Guid("1D3A7A18-F345-4201-81AA-8FC8A4029F4E"), new Guid("596E6BE3-D0C1-4C17-AF75-BFCDBD972627"), new Guid("208EA94D-638B-4724-9272-DF1383FF9452"), new Guid("DEDAA6F6-CA6D-486E-B0B8-254A477E697F"), new Guid("4C7EEA30-510E-45BD-8DBB-3EC1AF5E563A"), new Guid("8B87B87D-43D0-4BBE-8E2C-8EC84C983A42"), new Guid("40E44905-4CDE-4470-8E8B-527EE65C65DC"), new Guid("58E18F1C-5A4A-4E2E-869F-72D9C1512FE8") }; countries = guids.Select(g => CountryFactory.Create(g)).ToList(); transitStates = new List <TransitState>(); for (int i = 0; i < countries.Count - 1; i++) { var c = countries[i]; transitStates.Add(new TransitState(c, CompetentAuthorityFactory.Create(guids[i], c), EntryOrExitPointFactory.Create(guids[i], c), EntryOrExitPointFactory.Create(guids[i + 1], c), i + 1)); ObjectInstantiator <TransitState> .SetProperty(x => x.Id, guids[i], transitStates[i]); } this.validator = A.Fake <ITransportRouteValidator>(); }
public TransportRouteIntegration() { var userContext = A.Fake <IUserContext>(); A.CallTo(() => userContext.UserId).Returns(Guid.NewGuid()); context = new IwsContext(userContext, A.Fake <IEventDispatcher>()); this.validator = A.Fake <ITransportRouteValidator>(); }
public void SetStateOfImportForNotification(StateOfImport stateOfImport, ITransportRouteValidator validator) { Guard.ArgumentNotNull(() => stateOfImport, stateOfImport); Guard.ArgumentNotNull(() => validator, validator); if (!validator.IsImportAndExportStatesCombinationValid(stateOfImport, StateOfExport)) { throw new InvalidOperationException( string.Format( "Cannot add a State of Import in the same country as the State of Export for TransportRoute {0}. Country: {1}", Id, stateOfImport.Country.Name)); } StateOfImport = stateOfImport; }
public static TransportRoute CreateCompleted(Guid id, Guid notificationId, IList <EntryOrExitPoint> entryOrExitPoints, IList <CompetentAuthority> competentAuthorities, ITransportRouteValidator validator) { var transportRoute = new TransportRoute(notificationId); EntityHelper.SetEntityId(transportRoute, id); var exitPoint = entryOrExitPoints.OrderBy(ep => ep.Country.Name).First(ep => ep.Country.IsEuropeanUnionMember); var stateOfExport = new StateOfExport(exitPoint.Country, competentAuthorities.First(ca => ca.Country.Id == exitPoint.Country.Id), exitPoint); var entryPoint = entryOrExitPoints.OrderBy(ep => ep.Country.Name) .First(ep => ep.Country.IsEuropeanUnionMember && ep.Country.Id != exitPoint.Country.Id); var stateOfImport = new StateOfImport(entryPoint.Country, competentAuthorities.First(ca => ca.Country.Id == entryPoint.Country.Id), entryPoint); transportRoute.SetStateOfExportForNotification(stateOfExport, validator); transportRoute.SetStateOfImportForNotification(stateOfImport, validator); return(transportRoute); }
public SetExitCustomsOfficeForNotificationByIdHandlerTests() { this.context = new TestIwsContext(); var repository = A.Fake <ITransportRouteRepository>(); anyNotification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 0); EntityHelper.SetEntityId(anyNotification, notificationId); transport = new TransportRoute(notificationId); context.NotificationApplications.Add(anyNotification); context.TransportRoutes.Add(transport); country = CountryFactory.Create(AnyGuid); nonEuCountry = CountryFactory.Create(new Guid("606ECF5A-6571-4803-9CCA-7E1AF82D147A"), "test", false); context.Countries.AddRange(new[] { country, nonEuCountry }); stateOfExport = new StateOfExport(country, CompetentAuthorityFactory.Create(AnyGuid, country), EntryOrExitPointFactory.Create(AnyGuid, country)); stateOfImportNonEu = new StateOfImport(nonEuCountry, CompetentAuthorityFactory.Create(new Guid("5E4F1F22-5054-449B-9EC7-933A43BB5D6D"), nonEuCountry), EntryOrExitPointFactory.Create(new Guid("9781324F-17B8-4009-89B2-C18963E3E6E1"), nonEuCountry)); A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport); this.handler = new SetExitCustomsOfficeForNotificationByIdHandler(context, repository); this.validator = A.Fake <ITransportRouteValidator>(); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(stateOfImportNonEu, stateOfExport)).Returns(true); }