private StateOfExport GenerateStateOfExport(Draft.StateOfExport stateOfExport, TransportRouteLookups lookups) { var returnValue = new StateOfExport(); if (stateOfExport.CompetentAuthorityId.HasValue) { var competentAuthority = lookups.GetCompetentAuthority(stateOfExport.CompetentAuthorityId); returnValue.CompetentAuthorityName = competentAuthority.Name; returnValue.CompetentAuthorityCode = competentAuthority.Code; } if (stateOfExport.CountryId.HasValue) { returnValue.CountryName = lookups.GetCountry(stateOfExport.CountryId).Name; } if (stateOfExport.ExitPointId.HasValue) { returnValue.ExitPointName = lookups.GetEntryOrExitPoint(stateOfExport.ExitPointId).Name; } return(returnValue); }
public void SetStateOfImport_SameCountryToStateOfExportIfNoSameCountryExportsAllowed_Throws() { // Arrange var exportCountry = countries[0]; var exportCompetentAuthority = CompetentAuthorityFactory.Create(guids[0], exportCountry); var exportExitPoint = EntryOrExitPointFactory.Create(guids[0], exportCountry); var importCompetentAuthority = CompetentAuthorityFactory.Create(guids[1], exportCountry); var importExitPoint = EntryOrExitPointFactory.Create(guids[1], exportCountry); var stateOfExport = new StateOfExport(exportCountry, exportCompetentAuthority, exportExitPoint); var stateOfImport = new StateOfImport(exportCountry, importCompetentAuthority, importExitPoint); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(stateOfImport, stateOfExport)).Returns(false); // Act var intraCountryExportAlloweds = new TestableIntraCountryExportAllowed[0]; transportRoute.SetStateOfExportForNotification(stateOfExport, this.validator); // Assert Assert.Throws <InvalidOperationException>(() => transportRoute.SetStateOfImportForNotification(stateOfImport, this.validator)); }
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); }
public async Task CanAddStateOfExport() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Disposal, UKCompetentAuthority.England, 450); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var transport = new TransportRoute(notification.Id); context.TransportRoutes.Add(transport); await context.SaveChangesAsync(); var exitPoint = await context.EntryOrExitPoints.FirstAsync(); var country = exitPoint.Country; var competentAuthority = await context.CompetentAuthorities.FirstAsync(ca => ca.Country.Id == country.Id); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); transport.SetStateOfExportForNotification(stateOfExport); await context.SaveChangesAsync(); Assert.Equal(country.Id, transport.StateOfExport.Country.Id); Assert.Equal(competentAuthority.Id, transport.StateOfExport.CompetentAuthority.Id); Assert.Equal(exitPoint.Id, transport.StateOfExport.ExitPoint.Id); await DeleteEntity(stateOfExport); await DeleteEntity(transport); await DeleteEntity(notification); }
public async Task <Guid> HandleAsync(SetStateOfExportForNotification message) { var notification = await context.GetNotificationApplication(message.NotificationId); var transportRoute = await transportRouteRepository.GetByNotificationId(message.NotificationId); var country = await context.Countries.SingleAsync(c => c.Name == UnitedKingdomCompetentAuthority.CountryName); var exitPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.EntryOrExitPointId); var acceptableExportStates = await iceaRepository.GetAllAsync(); var unitedKingdomAuthorities = await context.UnitedKingdomCompetentAuthorities.ToArrayAsync(); if (transportRoute == null) { transportRoute = new TransportRoute(message.NotificationId); context.TransportRoutes.Add(transportRoute); } var ukcompAuth = await unitedKingdomCompetentAuthorityRepository.GetByCompetentAuthority(notification.CompetentAuthority); var caid = ukcompAuth.CompetentAuthority.Id; var competentAuthority = await context.CompetentAuthorities.SingleAsync(ca => ca.Id == caid); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); var validator = new TransportRouteValidation(acceptableExportStates, unitedKingdomAuthorities); transportRoute.SetStateOfExportForNotification(stateOfExport, validator); await context.SaveChangesAsync(); return(stateOfExport.Id); }
public TransportRouteData(IList <TransitState> transitStates, StateOfExport stateOfExport, StateOfImport stateOfImport, bool hasNoTransitStates) { TransitStates = transitStates; StateOfExport = stateOfExport; StateOfImport = stateOfImport; HasNoTransitStates = hasNoTransitStates; }
public TransportRouteData(IList<TransitState> transitStates, StateOfExport stateOfExport, StateOfImport stateOfImport, bool hasNoTransitStates) { TransitStates = transitStates; StateOfExport = stateOfExport; StateOfImport = stateOfImport; HasNoTransitStates = hasNoTransitStates; }
public void CustomsOfficesRequired_TransitStatesInEU_None() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.EntryAndExit, result); }
public void CustomsOfficesRequired_StateOfImportOutsideEU_Exit() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.EntryAndExit, result); }
public void StateOfExport_AllCountriesMatch_ReturnsNewStateOfExport() { var country = GetTestCountry(Guid.Empty); var competentAuthority = ObjectInstantiator<CompetentAuthority>.CreateNew(); ObjectInstantiator<CompetentAuthority>.SetProperty(x => x.Country, country, competentAuthority); var exitPoint = ObjectInstantiator<EntryOrExitPoint>.CreateNew(); ObjectInstantiator<EntryOrExitPoint>.SetProperty(x => x.Country, country, exitPoint); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); Assert.NotNull(stateOfExport); }
public async Task CanUpdateStateOfExport() { var notification = NotificationApplicationFactory.Create(Guid.NewGuid(), NotificationType.Disposal, UKCompetentAuthority.England, 450); context.NotificationApplications.Add(notification); await context.SaveChangesAsync(); var transport = new TransportRoute(notification.Id); context.TransportRoutes.Add(transport); await context.SaveChangesAsync(); var exitPoint = context.EntryOrExitPoints.First(); var country = exitPoint.Country; var competentAuthority = context.CompetentAuthorities.First(ca => ca.Country.Id == country.Id); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); IntraCountryExportAllowed[] intraCountryExportAlloweds = new IntraCountryExportAllowed[0]; A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true); transport.SetStateOfExportForNotification(stateOfExport, this.validator); await context.SaveChangesAsync(); var nextExitPoint = context.EntryOrExitPoints.First(ep => ep.Id != exitPoint.Id); if (nextExitPoint.Country.Id != country.Id) { country = nextExitPoint.Country; competentAuthority = context.CompetentAuthorities.First(ca => ca.Country.Id == country.Id); } var newStateOfExport = new StateOfExport(country, competentAuthority, nextExitPoint); A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, newStateOfExport)).Returns(true); transport.SetStateOfExportForNotification(newStateOfExport, this.validator); await context.SaveChangesAsync(); Assert.Equal(nextExitPoint.Id, transport.StateOfExport.ExitPoint.Id); DatabaseDataDeleter.DeleteDataForNotification(notification.Id, context); }
public void SetStateOfExport_NotificationAlreadyHasStateOfExport_Overwrites() { var competentAuthority = GetTestCompetentAuthority(countries[0]); var exitPoint = GetTestEntryOrExitPoint(countries[0]); var stateOfExport = new StateOfExport(countries[0], competentAuthority, exitPoint); transportRoute.SetStateOfExportForNotification(stateOfExport); transportRoute.SetStateOfExportForNotification(stateOfExport); Assert.Equal(stateOfExport.Country.Id, transportRoute.StateOfExport.Country.Id); }
public void SetExitCustomsOffice_NotRequired_Throws() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); Assert.Throws<InvalidOperationException>( () => transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("test", "test", europeanCountry1))); }
public void StateOfExport_AllCountriesMatch_ReturnsNewStateOfExport() { var country = GetTestCountry(Guid.Empty); var competentAuthority = ObjectInstantiator <CompetentAuthority> .CreateNew(); ObjectInstantiator <CompetentAuthority> .SetProperty(x => x.Country, country, competentAuthority); var exitPoint = ObjectInstantiator <EntryOrExitPoint> .CreateNew(); ObjectInstantiator <EntryOrExitPoint> .SetProperty(x => x.Country, country, exitPoint); var stateOfExport = new StateOfExport(country, competentAuthority, exitPoint); Assert.NotNull(stateOfExport); }
public void SetExitCustomsOffice_Required_Sets() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("test", "test", europeanCountry1)); Assert.Equal("test", transportRoute.ExitCustomsOffice.Name); Assert.Equal("test", transportRoute.ExitCustomsOffice.Address); Assert.Equal(europeanCountry1.Id, transportRoute.ExitCustomsOffice.Country.Id); }
public void SetStateOfExport_NotificationAlreadyHasStateOfExport_Overwrites() { var competentAuthority = GetTestCompetentAuthority(countries[0]); var exitPoint = GetTestEntryOrExitPoint(countries[0]); var stateOfExport = new StateOfExport(countries[0], competentAuthority, exitPoint); var intraCountryExportAlloweds = new TestableIntraCountryExportAllowed[0]; A.CallTo(() => this.validator.IsImportAndExportStatesCombinationValid(null, stateOfExport)).Returns(true); transportRoute.SetStateOfExportForNotification(stateOfExport, this.validator); Assert.Equal(stateOfExport.Country.Id, transportRoute.StateOfExport.Country.Id); }
public async Task<ActionResult> Index(Guid id, StateOfExportViewModel model) { if (!ModelState.IsValid) { return View(model); } var stateOfExport = new StateOfExport(id) { CompetentAuthorityId = model.CompetentAuthorityId, CountryId = model.CountryId, ExitPointId = model.ExitPointId }; await mediator.SendAsync(new SetDraftData<StateOfExport>(id, stateOfExport)); return RedirectToAction("Index", "StateOfImport"); }
public async Task <ActionResult> Index(Guid id, StateOfExportViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var stateOfExport = new StateOfExport(id) { CompetentAuthorityId = model.CompetentAuthorityId, CountryId = model.CountryId, ExitPointId = model.ExitPointId }; await mediator.SendAsync(new SetDraftData <StateOfExport>(id, stateOfExport)); return(RedirectToAction("Index", "StateOfImport")); }
public void CustomsOfficesRequired_StateOfTransitInsideEUImportOutside_Exit() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(nonEuCountry2, nonEuCompetentAuthority2, nonEuEntryOrExitPoints2[0]); var transitState = new TransitState(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0], europeanEntryOrExitPoints2[1], 1); transportRoute.AddTransitStateToNotification(transitState); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.EntryAndExit, result); }
public static TransportRoute CreateCompleted(Guid id, Guid notificationId, IList<EntryOrExitPoint> entryOrExitPoints, IList<CompetentAuthority> competentAuthorities) { 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); transportRoute.SetStateOfImportForNotification(stateOfImport); return transportRoute; }
public void SetEntryCustomsOffice_Required_Sets() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var transitState = new TransitState(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0], nonEuEntryOrExitPoints1[1], 1); var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); transportRoute.AddTransitStateToNotification(transitState); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test", "test", europeanCountry1)); Assert.Equal("test", transportRoute.EntryCustomsOffice.Name); Assert.Equal("test", transportRoute.EntryCustomsOffice.Address); Assert.Equal(europeanCountry1.Id, transportRoute.EntryCustomsOffice.Country.Id); }
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); }
public bool IsImportAndExportStatesCombinationValid(StateOfImport importState, StateOfExport exportState) { return(true); }
public TransportRouteTests() { stateOfImport = new StateOfImport(anyGuid, anyGuid); stateOfExport = new StateOfExport(anyGuid, anyGuid, anyGuid); }
public void CustomsOfficesRequired_StateOfImportOutsideEU_Exit() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.Exit, result); }
public void CanCreateStateOfExport() { var stateOfImport = new StateOfExport(anyGuid, anyGuid, anyGuid); Assert.IsType<StateOfExport>(stateOfImport); }
private StateOfExport GenerateStateOfExport(Draft.StateOfExport stateOfExport, TransportRouteLookups lookups) { var returnValue = new StateOfExport(); if (stateOfExport.CompetentAuthorityId.HasValue) { var competentAuthority = lookups.GetCompetentAuthority(stateOfExport.CompetentAuthorityId); returnValue.CompetentAuthorityName = competentAuthority.Name; returnValue.CompetentAuthorityCode = competentAuthority.Code; } if (stateOfExport.CountryId.HasValue) { returnValue.CountryName = lookups.GetCountry(stateOfExport.CountryId).Name; } if (stateOfExport.ExitPointId.HasValue) { returnValue.ExitPointName = lookups.GetEntryOrExitPoint(stateOfExport.ExitPointId).Name; } return returnValue; }
private void SetStateOfExport(StateOfExport stateOfExport) { ObjectInstantiator <TransportRoute> .SetProperty(x => x.StateOfExport, stateOfExport, transportRoute); }
public void CustomsOfficesRequired_ImportAndExportInsideEU_None() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.None, result); }
public void CustomsOfficesRequired_StateOfTransitInsideEUImportOutside_Exit() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var stateOfImport = new StateOfImport(nonEuCountry2, nonEuCompetentAuthority2, nonEuEntryOrExitPoints2[0]); var transitState = new TransitState(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0], europeanEntryOrExitPoints2[1], 1); transportRoute.AddTransitStateToNotification(transitState); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); var result = requiredCustomsOffices.GetForTransportRoute(transportRoute); Assert.Equal(CustomsOffices.Exit, result); }
public void RemoveOnlyNonEUTransitState_RaisesAllTransitStatesInEUEvent() { var importCountry = CountryFactory.Create(new Guid("EFFD18F8-32F1-48FE-8513-0FD5E45EF730")); var exportCountry = CountryFactory.Create(new Guid("FA92F4B9-CE86-44D7-8554-23D3B07A5269")); var transitCountry = CountryFactory.Create(new Guid("873F6164-3DFE-481E-B372-9BD530304E70"), isEuMember: false); var transitState = new TransitState( transitCountry, new TestableCompetentAuthority() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, 4); var transitStateId = new Guid("0BE78BE8-F666-4775-B3DA-7C058BFE4F4D"); EntityHelper.SetEntityId(transitState, transitStateId); var stateOfImport = new StateOfImport( importCountry, new TestableCompetentAuthority() { Country = importCountry }, new TestableEntryOrExitPoint() { Country = importCountry }); var stateOfExport = new StateOfExport( exportCountry, new TestableCompetentAuthority() { Country = exportCountry }, new TestableEntryOrExitPoint() { Country = exportCountry }); var validatorMock = A.Fake <ITransportRouteValidator>(); A.CallTo(() => validatorMock.IsImportAndExportStatesCombinationValid(stateOfImport, null)).Returns(true); A.CallTo(() => validatorMock.IsImportAndExportStatesCombinationValid(stateOfImport, stateOfExport)).Returns(true); transportRoute.SetStateOfImportForNotification( stateOfImport, validatorMock); transportRoute.SetStateOfExportForNotification( stateOfExport, validatorMock); transportRoute.AddTransitStateToNotification(transitState); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("entry", "entry", importCountry)); transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("exit", "exit", exportCountry)); transportRoute.RemoveTransitState(transitStateId); }
public StateOfExportViewModel(StateOfExport stateOfExport) { CountryId = stateOfExport.CountryId; CompetentAuthorityId = stateOfExport.CompetentAuthorityId; ExitPointId = stateOfExport.ExitPointId; }
public void SetStateOfImport_DifferentCountryToStateOfExport_SetsSuccessfully() { var exportCountry = countries[0]; var importCountry = countries[1]; var exportCompetentAuthority = GetTestCompetentAuthority(exportCountry); var exportExitPoint = GetTestEntryOrExitPoint(exportCountry); var importCompetentAuthority = GetTestCompetentAuthority(importCountry); var importExitPoint = GetTestEntryOrExitPoint(importCountry); var stateOfExport = new StateOfExport(exportCountry, exportCompetentAuthority, exportExitPoint); var stateOfImport = new StateOfImport(importCountry, importCompetentAuthority, importExitPoint); // Act transportRoute.SetStateOfExportForNotification(stateOfExport); transportRoute.SetStateOfImportForNotification(stateOfImport); // Assert Assert.Equal(importCountry.Id, transportRoute.StateOfImport.Country.Id); }
private void SetStateOfExport(StateOfExport stateOfExport) { ObjectInstantiator<TransportRoute>.SetProperty(x => x.StateOfExport, stateOfExport, transportRoute); }
public void SetEntryCustomsOffice_Required_OverwritesPrevious() { var stateOfExport = new StateOfExport(europeanCountry1, europeanCompetentAuthority1, europeanEntryOrExitPoints1[0]); var transitState = new TransitState(nonEuCountry1, nonEuCompetentAuthority1, nonEuEntryOrExitPoints1[0], nonEuEntryOrExitPoints1[1], 1); var stateOfImport = new StateOfImport(europeanCountry2, europeanCompetentAuthority2, europeanEntryOrExitPoints2[0]); SetStateOfExport(stateOfExport); SetStateOfImport(stateOfImport); transportRoute.AddTransitStateToNotification(transitState); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test", "test", europeanCountry1)); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("test2", "test2", europeanCountry2)); Assert.Equal("test2", transportRoute.EntryCustomsOffice.Name); Assert.Equal("test2", transportRoute.EntryCustomsOffice.Address); Assert.Equal(europeanCountry2.Id, transportRoute.EntryCustomsOffice.Country.Id); }
public void SetStateOfImport_SameCountryToStateOfExport_Throws() { // Arrange var exportCountry = countries[0]; var exportCompetentAuthority = CompetentAuthorityFactory.Create(guids[0], exportCountry); var exportExitPoint = EntryOrExitPointFactory.Create(guids[0], exportCountry); var importCompetentAuthority = CompetentAuthorityFactory.Create(guids[1], exportCountry); var importExitPoint = EntryOrExitPointFactory.Create(guids[1], exportCountry); var stateOfExport = new StateOfExport(exportCountry, exportCompetentAuthority, exportExitPoint); var stateOfImport = new StateOfImport(exportCountry, importCompetentAuthority, importExitPoint); // Act transportRoute.SetStateOfExportForNotification(stateOfExport); // Assert Assert.Throws<InvalidOperationException>(() => transportRoute.SetStateOfImportForNotification(stateOfImport)); }
public void CanCreateStateOfExport() { var stateOfImport = new StateOfExport(anyGuid, anyGuid, anyGuid); Assert.IsType <StateOfExport>(stateOfImport); }