//public IList<MergeField> AnnexMergeFields { get; private set; } public CustomsOfficeBlock(IList<MergeField> mergeFields, TransportRoute transportRoute) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new CustomsOfficeViewModel(transportRoute); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
/// <summary> /// Adds a new entry to the overview /// </summary> /// <param name="transportRoute"></param> /// <returns></returns> public TransportRouteOverviewElementView Add(TransportRoute transportRoute) { TransportRouteOverviewElementView transportRouteOverviewView = GameObject.Instantiate(overviewElementViewPrefab, _routeOverviewScrollView); transportRouteOverviewView.TransportRoute = transportRoute; return(transportRouteOverviewView); }
public GetExitCustomsOfficeAddDataByNotificationIdTests() { context = new TestIwsContext(); var repository = A.Fake <ITransportRouteRepository>(); country = CountryFactory.Create(new Guid("05C21C57-2F39-4A15-A09A-5F38CF139C05")); exitCustomsOffice = new ExitCustomsOffice("any name", "any address", country); notification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 500); transport = new TransportRoute(NotificationId); EntityHelper.SetEntityId(notification, NotificationId); context.Countries.Add(country); context.NotificationApplications.Add(notification); context.TransportRoutes.Add(transport); A.CallTo(() => repository.GetByNotificationId(NotificationId)).Returns(transport); handler = new GetExitCustomsOfficeAddDataByNotificationIdHandler(repository, new CustomsOfficeExitMap(context, new CountryMap(), new CustomsOfficeMap(new CountryMap()))); }
public TransitStatesBlock(IList<MergeField> mergeFields, TransportRoute transportRoute) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new TransitStateViewModel(transportRoute.TransitStates.ToList()); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
public virtual void CopyTransportRouteWithoutExport(TransportRoute source, TransportRoute destination, IEnumerable <IntraCountryExportAllowed> intraCountryExportAlloweds) { CopyStateOfImport(source, destination, intraCountryExportAlloweds); CopyTransitStates(source, destination); CopyCustomsOffices(source, destination); CopyEntryExitCustomsOfficeSelection(source, destination); }
public CustomsOfficeViewModel(TransportRoute transportRoute) { EntryTitle = transportRoute.EntryCustomsOffice != null ? "Entry customs office:" : string.Empty; ExitTitle = transportRoute.ExitCustomsOffice != null ? "Exit customs office:" : string.Empty; EntryName = transportRoute.EntryCustomsOffice != null ? transportRoute.EntryCustomsOffice.Name : string.Empty; ExitName = transportRoute.ExitCustomsOffice != null ? transportRoute.ExitCustomsOffice.Name : string.Empty; EntryAddress = transportRoute.EntryCustomsOffice != null ? transportRoute.EntryCustomsOffice.Address : string.Empty; ExitAddress = transportRoute.ExitCustomsOffice != null ? transportRoute.ExitCustomsOffice.Address : string.Empty; EntryCountry = transportRoute.EntryCustomsOffice != null ? transportRoute.EntryCustomsOffice.Country.Name : string.Empty; ExitCountry = transportRoute.ExitCustomsOffice != null ? transportRoute.ExitCustomsOffice.Country.Name : string.Empty; EntryAnnexMessage = string.Empty; ExitAnnexMessage = string.Empty; SetIsAnnexNeeded(transportRoute); CustomsOfficeData = string.Empty; }
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 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]); } }
public GetExitCustomsOfficeAddDataByNotificationIdTests() { context = new TestIwsContext(); var repository = A.Fake<ITransportRouteRepository>(); country = CountryFactory.Create(new Guid("05C21C57-2F39-4A15-A09A-5F38CF139C05")); exitCustomsOffice = new ExitCustomsOffice("any name", "any address", country); notification = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 500); transport = new TransportRoute(NotificationId); EntityHelper.SetEntityId(notification, NotificationId); context.Countries.Add(country); context.NotificationApplications.Add(notification); context.TransportRoutes.Add(transport); A.CallTo(() => repository.GetByNotificationId(NotificationId)).Returns(transport); handler = new GetExitCustomsOfficeAddDataByNotificationIdHandler(repository, new CustomsOfficeExitMap(context, new CountryMap(), new CustomsOfficeMap(new CountryMap()))); }
public TransitStatesBlock(IList <MergeField> mergeFields, TransportRoute transportRoute) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new TransitStateViewModel(transportRoute.TransitStates.ToList()); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
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 async Task <CustomsOfficeCompletionStatus> HandleAsync(SetEntryCustomsOfficeForNotificationById message) { var transportRoute = await repository.GetByNotificationId(message.Id); var requiredCustomsOffices = new RequiredCustomsOffices(); if (transportRoute == null) { transportRoute = new TransportRoute(message.Id); context.TransportRoutes.Add(transportRoute); } var country = await context.Countries.SingleAsync(c => c.Id == message.CountryId); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice(message.Name, message.Address, country)); await context.SaveChangesAsync(); return(new CustomsOfficeCompletionStatus { CustomsOfficesRequired = requiredCustomsOffices.GetForTransportRoute(transportRoute) }); }
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>(); }
private async Task <TransportRoute> CloneTransportRoute(Guid sourceNotificationId, Guid destinationNotificationId, UKCompetentAuthority destinationCompetentAuthority) { var transportRoute = await context.TransportRoutes.SingleOrDefaultAsync(p => p.NotificationId == sourceNotificationId); var destinationTransportRoute = new TransportRoute(destinationNotificationId); if (transportRoute != null) { var sourceCompetentAuthority = (await notificationApplicationRepository.GetById(sourceNotificationId)).CompetentAuthority; var intraCountryExportAlloweds = await intraCountryExportAllowedRepository.GetAllAsync(); if (destinationCompetentAuthority == sourceCompetentAuthority) { transportRouteCopier.CopyTransportRoute(transportRoute, destinationTransportRoute, intraCountryExportAlloweds); } else { transportRouteCopier.CopyTransportRouteWithoutExport(transportRoute, destinationTransportRoute, intraCountryExportAlloweds); } } context.TransportRoutes.Add(destinationTransportRoute); await context.SaveChangesAsync(); return(destinationTransportRoute); }
public async Task <Unit> HandleAsync(AddTransitState message) { var transportRoute = await repository.GetByNotificationId(message.NotificationId); if (transportRoute == null) { transportRoute = new TransportRoute(message.NotificationId); context.TransportRoutes.Add(transportRoute); } var country = await context.Countries.SingleAsync(c => c.Id == message.CountryId); var competentAuthority = await context.CompetentAuthorities.SingleAsync(ca => ca.Id == message.CompetentAuthorityId); var entryPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.EntryPointId); var exitPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.ExitPointId); var ordinalPosition = transportRoute.GetAvailableTransitStatePositions().First(); var transitState = new TransitState(country, competentAuthority, entryPoint, exitPoint, ordinalPosition); transportRoute.AddTransitStateToNotification(transitState); await context.SaveChangesAsync(); return(Unit.Value); }
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(SetStateOfImportForNotification message) { var transportRoute = await repository.GetByNotificationId(message.NotificationId); if (transportRoute == null) { transportRoute = new TransportRoute(message.NotificationId); context.TransportRoutes.Add(transportRoute); } var country = await context.Countries.SingleAsync(c => c.Id == message.CountryId); var competentAuthority = await context.CompetentAuthorities.SingleAsync(ca => ca.Id == message.CompetentAuthorityId); var entryPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.EntryOrExitPointId); var stateOfImport = new StateOfImport(country, competentAuthority, entryPoint); var acceptableImportStates = await iceaRepository.GetAllAsync(); var validator = new TransportRouteValidation(await iceaRepository.GetAllAsync(), await this.context.UnitedKingdomCompetentAuthorities.ToArrayAsync()); transportRoute.SetStateOfImportForNotification(stateOfImport, validator); await context.SaveChangesAsync(); return(stateOfImport.Id); }
protected virtual void CopyEntryExitCustomsOfficeSelection(TransportRoute source, TransportRoute destination) { if (source.EntryExitCustomsOfficeSelection != null) { destination.SetEntryExitCustomsOfficeSelection(new EntryExitCustomsOfficeSelection(source.EntryExitCustomsOfficeSelection.Entry, source.EntryExitCustomsOfficeSelection.Exit)); } }
public CustomsOfficeBlock(IList <MergeField> mergeFields, TransportRoute transportRoute, UKCompetentAuthority notificationCompetentAuthority) { IsNorthenIrelandCompetentAuthority = (notificationCompetentAuthority.Equals(UKCompetentAuthority.NorthernIreland) ? true : false); CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new CustomsOfficeViewModel(transportRoute); AnnexMergeFields = MergeFieldLocator.GetAnnexMergeFields(mergeFields, TypeName); }
public TransportViewModel(TransportRoute transportRoute) { ExportCountry = transportRoute.StateOfExport.Country.Name; ExportCompetentAuthority = transportRoute.StateOfExport.CompetentAuthority.Code; ExitPoint = transportRoute.StateOfExport.ExitPoint.Name; ImportCountry = transportRoute.StateOfImport.Country.Name; ImportCompetentAuthority = transportRoute.StateOfImport.CompetentAuthority.Code; EntryPoint = transportRoute.StateOfImport.EntryPoint.Name; }
protected virtual void CopyStateOfImport(TransportRoute source, TransportRoute destination, IEnumerable <IntraCountryExportAllowed> intraCountryExportAlloweds) { if (source.StateOfImport != null) { destination.SetStateOfImportForNotification(new StateOfImport(source.StateOfImport.Country, source.StateOfImport.CompetentAuthority, source.StateOfImport.EntryPoint), validator); } }
public NotificationTransitStateTests() { transportRoute = new TransportRoute(AnyGuid); var firstCountry = CountryFactory.Create(new Guid("A5E60A6E-D237-461F-8737-FE8190CEC1BC")); var secondCountry = CountryFactory.Create(new Guid("DB611B2D-2EF2-42AA-8857-B4B953D91767")); var thirdCountry = CountryFactory.Create(new Guid("C5C282CE-D4A6-4F81-BCD9-2518098D1D85")); transportRoute.AddTransitStateToNotification(TransitStateFactory.Create(FirstTransitStateId, firstCountry, 1)); transportRoute.AddTransitStateToNotification(TransitStateFactory.Create(SecondTransitStateId, secondCountry, 2)); transportRoute.AddTransitStateToNotification(TransitStateFactory.Create(ThirdTransitStateId, thirdCountry, 3)); }
protected virtual void CopyTransitStates(TransportRoute source, TransportRoute destination) { if (source.TransitStates != null) { foreach (var transitState in source.TransitStates.OrderBy(ts => ts.OrdinalPosition)) { destination.AddTransitStateToNotification(new TransitState(transitState.Country, transitState.CompetentAuthority, transitState.EntryPoint, transitState.ExitPoint, transitState.OrdinalPosition)); } } }
public new void Reset() { _selectedTransportRoute = null; _createButton.gameObject.SetActive(true); _applyButton.gameObject.SetActive(false); _vehicleToggle.interactable = true; _vehicleToggle.isOn = true; _routeToggle.isOn = false; _routeToggle.interactable = false; _createButton.interactable = false; vehicleChoiceSubView.Reset(); SettingController.Reset(); _stationManager.Reset(); }
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); }
/// <summary> /// Removes an old entry from the overview /// </summary> /// <param name="transportRoute">the transport route to be removed</param> /// <returns>true if the element was found. </returns> public bool Remove(TransportRoute transportRoute) { Debug.Log("Remove Overview Element"); for (int i = 0; i < _routeOverviewScrollView.childCount; i++) { TransportRouteOverviewElementView elementView = _routeOverviewScrollView.GetChild(i).gameObject.GetComponent <TransportRouteOverviewElementView>(); if (elementView.TransportRoute != transportRoute) { continue; } Destroy(_routeOverviewScrollView.GetChild(i).gameObject); return(true); } return(false); }
protected virtual void CopyCustomsOffices(TransportRoute source, TransportRoute destination) { if (source.EntryCustomsOffice != null) { destination.SetEntryCustomsOffice(new EntryCustomsOffice(source.EntryCustomsOffice.Name, source.EntryCustomsOffice.Address, source.EntryCustomsOffice.Country)); } if (source.ExitCustomsOffice != null) { destination.SetExitCustomsOffice(new ExitCustomsOffice(source.ExitCustomsOffice.Name, source.ExitCustomsOffice.Address, source.ExitCustomsOffice.Country)); } }
public void CanSetTransitStates() { var transportRoute = new TransportRoute(anyGuid, stateOfExport, stateOfImport); var transitStates = new[] { new TransitState(anyGuid, anyGuid, anyGuid, anyGuid, 1), new TransitState(anyGuid, anyGuid, anyGuid, anyGuid, 2), new TransitState(anyGuid, anyGuid, anyGuid, anyGuid, 3) }; var transitStatesList = new TransitStateList(transitStates); transportRoute.SetTransitStates(transitStatesList); Assert.Equal(3, transportRoute.TransitStates.Count()); }
public CustomsOfficeViewModel(TransportRoute transportRoute) { EntryTitle = transportRoute.EntryCustomsOffice != null ? "Entry customs office:" : string.Empty; ExitTitle = transportRoute.ExitCustomsOffice != null ? "Exit customs office:" : string.Empty; EntryName = transportRoute.EntryCustomsOffice != null ? transportRoute.EntryCustomsOffice.Name : string.Empty; ExitName = transportRoute.ExitCustomsOffice != null ? transportRoute.ExitCustomsOffice.Name : string.Empty; EntryAddress = transportRoute.EntryCustomsOffice != null ? transportRoute.EntryCustomsOffice.Address : string.Empty; ExitAddress = transportRoute.ExitCustomsOffice != null ? transportRoute.ExitCustomsOffice.Address : string.Empty; EntryAnnexMessage = string.Empty; ExitAnnexMessage = string.Empty; SetIsAnnexNeeded(transportRoute); }
public async Task <Guid> HandleAsync(SetTransitStateForNotification message) { var transportRoute = await repository.GetByNotificationId(message.NotificationId); if (transportRoute == null) { transportRoute = new TransportRoute(message.NotificationId); context.TransportRoutes.Add(transportRoute); } var country = await context.Countries.SingleAsync(c => c.Id == message.CountryId); var competentAuthority = await context.CompetentAuthorities.SingleAsync(ca => ca.Id == message.CompetentAuthorityId); var entryPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.EntryPointId); var exitPoint = await context.EntryOrExitPoints.SingleAsync(ep => ep.Id == message.ExitPointId); Guid result; if (message.TransitStateId.HasValue) { transportRoute.UpdateTransitStateForNotification(message.TransitStateId.Value, country, competentAuthority, entryPoint, exitPoint, message.OrdinalPosition); result = message.TransitStateId.Value; } else { var ordinalPosition = transportRoute.GetAvailableTransitStatePositions().First(); var transitState = new TransitState(country, competentAuthority, entryPoint, exitPoint, ordinalPosition); result = transitState.Id; transportRoute.AddTransitStateToNotification(transitState); } await context.SaveChangesAsync(); return(result); }
public GetCustomsOfficeRequiredStatusByNotificationIdHandlerTests() { notification1 = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 500); notificationId = new Guid("295B0511-D0EB-43B4-9D17-938E1A34F0D3"); EntityHelper.SetEntityId(notification1, notificationId); var transport = new TransportRoute(notificationId); context = new TestIwsContext(); context.NotificationApplications.Add(notification1); context.TransportRoutes.Add(transport); var repository = A.Fake<ITransportRouteRepository>(); A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport); handler = new GetCustomsCompletionStatusByNotificationIdHandler(repository); }
public GetCustomsOfficeRequiredStatusByNotificationIdHandlerTests() { notification1 = NotificationApplicationFactory.Create(TestIwsContext.UserId, NotificationType.Recovery, UKCompetentAuthority.England, 500); notificationId = new Guid("295B0511-D0EB-43B4-9D17-938E1A34F0D3"); EntityHelper.SetEntityId(notification1, notificationId); var transport = new TransportRoute(notificationId); context = new TestIwsContext(); context.NotificationApplications.Add(notification1); context.TransportRoutes.Add(transport); var repository = A.Fake <ITransportRouteRepository>(); A.CallTo(() => repository.GetByNotificationId(notificationId)).Returns(transport); handler = new GetCustomsCompletionStatusByNotificationIdHandler(repository); }
public RemoveTransitStateForNotificationHandlerTests() { var userContext = A.Fake<IUserContext>(); A.CallTo(() => userContext.UserId).Returns(Guid.Empty); context = new TestIwsContext(userContext); var notification = NotificationApplicationFactory.Create(ExistingNotificationId); var transport = new TransportRoute(ExistingNotificationId); transport.AddTransitStateToNotification(TransitStateFactory.Create(ExistingTransitStateId, CountryFactory.Create(new Guid("3E7A0092-B6CB-46AD-ABCC-FB741EB6CF35")), 1)); context.NotificationApplications.Add(notification); context.TransportRoutes.Add(transport); var repository = A.Fake<ITransportRouteRepository>(); A.CallTo(() => repository.GetByNotificationId(ExistingNotificationId)).Returns(transport); handler = new RemoveTransitStateForNotificationHandler(context, repository); }
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 NotificationCustomsOfficeTests() { transportRoute = new TransportRoute(Guid.Empty); europeanCountry1 = CreateCountry(new Guid("FB908C44-7AF1-4894-A0A5-860338468DFA"), true); europeanCountry2 = CreateCountry(new Guid("8057CD56-A12C-4C7D-BED4-B12D98DCADAB"), true); europeanCountry3 = CreateCountry(new Guid("BC0F57D1-6E22-4A15-A39E-1F34C91E49C6"), true); nonEuCountry1 = CreateCountry(new Guid("E9738924-B1EC-46E8-B45F-67D990E29D67"), false); nonEuCountry2 = CreateCountry(new Guid("04113907-94AF-41DB-A239-10803E067F68"), false); europeanCompetentAuthority1 = CreateCompetentAuthority(new Guid("532051C7-145E-4BA5-B950-CFC199B358A7"), europeanCountry1); europeanCompetentAuthority2 = CreateCompetentAuthority(new Guid("D274D346-E0F3-48EF-A54E-872319E37A97"), europeanCountry2); europeanCompetentAuthority3 = CreateCompetentAuthority(new Guid("02D11536-8564-4BAF-87A6-36CBAE7F6163"), europeanCountry3); nonEuCompetentAuthority1 = CreateCompetentAuthority(new Guid("2842CAAE-B34D-4311-A1DE-286EEF492AD6"), nonEuCountry1); nonEuCompetentAuthority2 = CreateCompetentAuthority(new Guid("F84CF9EF-A98A-4B8F-B4EC-C3185833226B"), nonEuCountry2); SetTransitStates(); }
public async Task <bool> HandleAsync(SetEntryCustomsOfficeSelectionForNotificationById message) { var transportRoute = await repository.GetByNotificationId(message.Id); var requiredCustomsOffices = new RequiredCustomsOffices(); if (transportRoute == null) { transportRoute = new TransportRoute(message.Id); context.TransportRoutes.Add(transportRoute); } bool?existingExit = transportRoute.EntryExitCustomsOfficeSelection != null ? transportRoute.EntryExitCustomsOfficeSelection.Exit : null; var selection = new EntryExitCustomsOfficeSelection(message.Selection, existingExit); transportRoute.SetEntryExitCustomsOfficeSelection(selection); await context.SaveChangesAsync(); return(true); }
public RemoveTransitStateForNotificationHandlerTests() { var userContext = A.Fake <IUserContext>(); A.CallTo(() => userContext.UserId).Returns(Guid.Empty); context = new TestIwsContext(userContext); var notification = NotificationApplicationFactory.Create(ExistingNotificationId); var transport = new TransportRoute(ExistingNotificationId); transport.AddTransitStateToNotification(TransitStateFactory.Create(ExistingTransitStateId, CountryFactory.Create(new Guid("3E7A0092-B6CB-46AD-ABCC-FB741EB6CF35")), 1)); context.NotificationApplications.Add(notification); context.TransportRoutes.Add(transport); var repository = A.Fake <ITransportRouteRepository>(); A.CallTo(() => repository.GetByNotificationId(ExistingNotificationId)).Returns(transport); handler = new RemoveTransitStateForNotificationHandler(context, repository); }
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 void CanCreateTransportRoute() { var transportRoute = new TransportRoute(anyGuid, stateOfExport, stateOfImport); Assert.IsType<TransportRoute>(transportRoute); }
public TransportBlock(IList<MergeField> mergeFields, TransportRoute transportRoute) { CorrespondingMergeFields = MergeFieldLocator.GetCorrespondingFieldsForBlock(mergeFields, TypeName); data = new TransportViewModel(transportRoute); }
public void Add(TransportRoute transportRoute) { context.TransportRoutes.Add(transportRoute); }
private void SetIsAnnexNeeded(TransportRoute transportRoute) { IsAnnexNeeded = transportRoute.EntryCustomsOffice != null || transportRoute.ExitCustomsOffice != null; }
public void CanCreateTransportRoute() { var transportRoute = new TransportRoute(anyGuid, stateOfExport, stateOfImport); Assert.IsType <TransportRoute>(transportRoute); }
public void AddToTransportRoutes(TransportRoute transportRoute) { base.AddObject("TransportRoutes", transportRoute); }
public static TransportRoute CreateTransportRoute(int ID, string transportRouteName, double distance, bool discontinued, byte[] rowVersion) { TransportRoute transportRoute = new TransportRoute(); transportRoute.Id = ID; transportRoute.TransportRouteName = transportRouteName; transportRoute.Distance = distance; transportRoute.Discontinued = discontinued; transportRoute.RowVersion = rowVersion; return transportRoute; }