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 void GetAvailableTransitStatePositions_WhereNotificationHasTwoStates_ReturnsThree() { var firstCountry = countries[0]; var secondCountry = countries[1]; var firstTransitState = new TransitState(firstCountry, GetTestCompetentAuthority(firstCountry), GetTestEntryOrExitPoint(firstCountry, guids[1]), GetTestEntryOrExitPoint(firstCountry, guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var secondTransitState = new TransitState(secondCountry, GetTestCompetentAuthority(secondCountry), GetTestEntryOrExitPoint(secondCountry, guids[3]), GetTestEntryOrExitPoint(secondCountry, guids[4]), 2); transportRoute.AddTransitStateToNotification(secondTransitState); int[] result = transportRoute.GetAvailableTransitStatePositions(); Assert.Equal(3, result[0]); }
public void AddTransitState_ToThirdPosition_AddsToNotification() { var firstCountry = countries[0]; var secondCountry = countries[1]; var thirdCountry = countries[2]; var firstTransitState = new TransitState(firstCountry, GetTestCompetentAuthority(firstCountry), GetTestEntryOrExitPoint(firstCountry, guids[1]), GetTestEntryOrExitPoint(firstCountry, guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var secondTransitState = new TransitState(secondCountry, GetTestCompetentAuthority(secondCountry), GetTestEntryOrExitPoint(secondCountry, guids[3]), GetTestEntryOrExitPoint(secondCountry, guids[4]), 2); transportRoute.AddTransitStateToNotification(secondTransitState); var thirdTransitState = new TransitState(thirdCountry, GetTestCompetentAuthority(thirdCountry), GetTestEntryOrExitPoint(thirdCountry, guids[5]), GetTestEntryOrExitPoint(thirdCountry, guids[6]), 3); transportRoute.AddTransitStateToNotification(thirdTransitState); Assert.Equal(3, transportRoute.TransitStates.Count()); }
public PlayerState(Point _pos, int _z_level, int _health, TransitState _state) { position = _pos; z_level = _z_level; health = _health; transit_state = _state; }
private static TransitState TransitState(Country country, string name) { var ca = CompetentAuthorityFactory.Create(Guid.Empty, country); var state = new TransitState(country, ca, EntryOrExitPointFactory.Create(Guid.Empty, country, name), EntryOrExitPointFactory.Create(Guid.NewGuid(), country, name), 1); return(state); }
public void GetCityId() { ManagedCountry c = new ManagedCountry(Session); ManagedState t = new ManagedState(Session); ManagedCity s = new ManagedCity(Session); try { TransitCountry tc = new TransitCountry(); tc.Name = GetNewString(); TransitState tt = new TransitState(); tt.Name = GetNewString(); tt.Country = tc.Name; TransitCity ts = new TransitCity(); ts.Name = GetNewString(); ts.Country = tc.Name; ts.State = tt.Name; c.CreateOrUpdate(tc, AdminSecurityContext); t.CreateOrUpdate(tt, AdminSecurityContext); Session.Flush(); s.CreateOrUpdate(ts, AdminSecurityContext); Session.Flush(); ManagedCity.GetCityId(Session, ts.Name, tt.Name, tc.Name); } finally { s.Delete(AdminSecurityContext); t.Delete(AdminSecurityContext); c.Delete(AdminSecurityContext); } }
private TransitState GenerateTransitState(Draft.TransitState transitState, TransportRouteLookups lookups) { var returnValue = new TransitState(); if (transitState.CompetentAuthorityId.HasValue) { var competentAuthority = lookups.GetCompetentAuthority(transitState.CompetentAuthorityId); returnValue.CompetentAuthorityCode = competentAuthority.Code; returnValue.CompetentAuthorityName = competentAuthority.Name; } if (transitState.CountryId.HasValue) { returnValue.CountryName = lookups.GetCountry(transitState.CountryId).Name; } if (transitState.EntryPointId.HasValue) { returnValue.EntryPointName = lookups.GetEntryOrExitPoint(transitState.EntryPointId).Name; } if (transitState.ExitPointId.HasValue) { returnValue.ExitPointName = lookups.GetEntryOrExitPoint(transitState.ExitPointId).Name; } return(returnValue); }
public TransitStateViewModel(TransitState transitState) { TransitStateId = transitState.Id; OrdinalPosition = transitState.OrdinalPosition; CompetentAuthorityId = transitState.CompetentAuthorityId; CountryId = transitState.CountryId; EntryPointId = transitState.EntryPointId; ExitPointId = transitState.ExitPointId; }
public TransitStateViewModel(TransitState transitState) { TransitStateId = transitState.Id; OrdinalPosition = transitState.OrdinalPosition; CompetentAuthorityId = transitState.CompetentAuthorityId; CountryId = transitState.CountryId; EntryPointId = transitState.EntryPointId; ExitPointId = transitState.ExitPointId; }
public void TransitState_EntryAndExitPointTheSame_Succeeds() { var country = countries[0]; var entryPoint = GetTestEntryOrExitPoint(country, new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54")); var exitPoint = GetTestEntryOrExitPoint(country, new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54")); var transitState = new TransitState(country, GetTestCompetentAuthority(country), entryPoint, exitPoint, 1); Assert.Equal(new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54"), transitState.EntryPoint.Id); Assert.Equal(new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54"), transitState.ExitPoint.Id); }
public void save_Click(object sender, EventArgs e) { TransitState tw = new TransitState(); tw.Name = inputName.Text; tw.Id = RequestId; tw.Country = inputCountry.SelectedItem.Value; SessionManager.CreateOrUpdate <TransitState>( tw, SessionManager.LocationService.CreateOrUpdateState); Redirect("SystemStatesManage.aspx"); }
public void save_Click(object sender, EventArgs e) { TransitState tw = new TransitState(); tw.Name = inputName.Text; tw.Id = RequestId; tw.Country = inputCountry.SelectedItem.Value; SessionManager.CreateOrUpdate<TransitState>( tw, SessionManager.LocationService.CreateOrUpdateState); Redirect("SystemStatesManage.aspx"); }
public void CreateManyPlaces(int count) { Random r = new Random(); ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session); // country TransitCountry t_country = new TransitCountry(); t_country.Name = Guid.NewGuid().ToString(); ManagedCountry country = new ManagedCountry(Session); country.CreateOrUpdate(t_country, sec); // state TransitState t_state = new TransitState(); t_state.Name = Guid.NewGuid().ToString(); t_state.Country = t_country.Name; ManagedState state = new ManagedState(Session); state.CreateOrUpdate(t_state, sec); // city TransitCity t_city = new TransitCity(); t_city.Name = Guid.NewGuid().ToString(); t_city.State = t_state.Name; t_city.Country = t_country.Name; ManagedCity city = new ManagedCity(Session); city.CreateOrUpdate(t_city, sec); // place type TransitPlaceType t_placetype = new TransitPlaceType(); t_placetype.Name = Guid.NewGuid().ToString(); ManagedPlaceType placetype = new ManagedPlaceType(Session); placetype.CreateOrUpdate(t_placetype, sec); for (int i = 0; i < count; i++) { TransitPlace t_place = new TransitPlace(); t_place.Name = Guid.NewGuid().ToString(); t_place.AccountId = sec.Account.Id; t_place.City = t_city.Name; t_place.Country = t_country.Name; t_place.State = t_state.Name; t_place.Street = string.Format("{0} {1} St.", r.Next(), Guid.NewGuid().ToString()); t_place.Zip = r.Next().ToString(); t_place.Type = t_placetype.Name; ManagedPlace place = new ManagedPlace(Session); place.CreateOrUpdate(t_place, sec); } }
public static TransitState Create(Guid id, Country country, int ordinalPosition) { // Note that the use of Guid.NewGuid() is non-deterministic and may cause random test failures. var transitState = new TransitState(country, CompetentAuthorityFactory.Create(Guid.NewGuid(), country), EntryOrExitPointFactory.Create(Guid.NewGuid(), country), EntryOrExitPointFactory.Create(Guid.NewGuid(), country), ordinalPosition); EntityHelper.SetEntityId(transitState, id); return(transitState); }
public static TransitState Create(Guid id, Country country, int ordinalPosition) { // Note that the use of Guid.NewGuid() is non-deterministic and may cause random test failures. var transitState = new TransitState(country, CompetentAuthorityFactory.Create(Guid.NewGuid(), country), EntryOrExitPointFactory.Create(Guid.NewGuid(), country), EntryOrExitPointFactory.Create(Guid.NewGuid(), country), ordinalPosition); EntityHelper.SetEntityId(transitState, id); return transitState; }
public void AddTransitState_OnlyTransitState_AddedSuccessfully() { var country = countries[1]; var transitState = new TransitState(country, GetTestCompetentAuthority(country), GetTestEntryOrExitPoint(country, Guid.Empty), GetTestEntryOrExitPoint(country, new Guid("E8E2D79A-F1CA-4928-9ED8-AAF961E2B7B7")), 1); transportRoute.AddTransitStateToNotification(transitState); Assert.True(transportRoute.TransitStates.Count() == 1); }
public void CreateManyAccounts(int count) { ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session); TransitCountry tc = new TransitCountry(); tc.Name = Guid.NewGuid().ToString(); TransitState ts = new TransitState(); ts.Name = Guid.NewGuid().ToString(); ts.Country = tc.Name; ManagedCountry c = new ManagedCountry(Session); c.CreateOrUpdate(tc, sec); ManagedState s = new ManagedState(Session); s.CreateOrUpdate(ts, sec); TransitAccountAddress ta = new TransitAccountAddress(); ta.Apt = "123"; ta.City = "New York"; ta.Country = tc.Name; ta.Name = "My Address"; ta.State = ts.Name; ta.Street = "Houston St."; ta.Zip = "10001"; for (int i = 0; i < count; i++) { ManagedAccount a = new ManagedAccount(Session); string name = Guid.NewGuid().ToString(); a.Create( name, "password", string.Format("{0}@localhost.com", name), DateTime.UtcNow, sec); ManagedAccountAddress ma = new ManagedAccountAddress(Session); ma.CreateOrUpdate(ta, a.GetSecurityContext()); } }
public void CreateManyPlaces(int count) { Random r = new Random(); ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session); // country TransitCountry t_country = new TransitCountry(); t_country.Name = Guid.NewGuid().ToString(); ManagedCountry country = new ManagedCountry(Session); country.CreateOrUpdate(t_country, sec); // state TransitState t_state = new TransitState(); t_state.Name = Guid.NewGuid().ToString(); t_state.Country = t_country.Name; ManagedState state = new ManagedState(Session); state.CreateOrUpdate(t_state, sec); // city TransitCity t_city = new TransitCity(); t_city.Name = Guid.NewGuid().ToString(); t_city.State = t_state.Name; t_city.Country = t_country.Name; ManagedCity city = new ManagedCity(Session); city.CreateOrUpdate(t_city, sec); // place type TransitPlaceType t_placetype = new TransitPlaceType(); t_placetype.Name = Guid.NewGuid().ToString(); ManagedPlaceType placetype = new ManagedPlaceType(Session); placetype.CreateOrUpdate(t_placetype, sec); for (int i = 0; i < count; i++) { TransitPlace t_place = new TransitPlace(); t_place.Name = Guid.NewGuid().ToString(); t_place.AccountId = sec.Account.Id; t_place.City = t_city.Name; t_place.Country = t_country.Name; t_place.State = t_state.Name; t_place.Street = string.Format("{0} {1} St.", r.Next(), Guid.NewGuid().ToString()); t_place.Zip = r.Next().ToString(); t_place.Type = t_placetype.Name; ManagedPlace place = new ManagedPlace(Session); place.CreateOrUpdate(t_place, sec); } }
public void AddTransitState_ToPositionOutOfRange_Throws() { var firstTransitState = new TransitState(countries[0], GetTestCompetentAuthority(countries[0]), GetTestEntryOrExitPoint(countries[0], guids[1]), GetTestEntryOrExitPoint(countries[0], guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var thirdTransitState = new TransitState(countries[1], GetTestCompetentAuthority(countries[1]), GetTestEntryOrExitPoint(countries[1], guids[3]), GetTestEntryOrExitPoint(countries[1], guids[4]), 3); Assert.Throws <InvalidOperationException>(() => transportRoute.AddTransitStateToNotification(thirdTransitState)); }
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 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 void AddTransitState_ReturnedInOrdinalOrder() { // Arrange var firstCountry = countries[0]; var secondCountry = countries[1]; var thirdCountry = countries[2]; var thirdTransitState = new TransitState(thirdCountry, GetTestCompetentAuthority(thirdCountry), GetTestEntryOrExitPoint(thirdCountry, guids[5]), GetTestEntryOrExitPoint(thirdCountry, guids[6]), 3); transportRoute.AddTransitStateToNotification(thirdTransitState); var firstTransitState = new TransitState(firstCountry, GetTestCompetentAuthority(firstCountry), GetTestEntryOrExitPoint(firstCountry, guids[1]), GetTestEntryOrExitPoint(firstCountry, guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var secondTransitState = new TransitState(secondCountry, GetTestCompetentAuthority(secondCountry), GetTestEntryOrExitPoint(secondCountry, guids[3]), GetTestEntryOrExitPoint(secondCountry, guids[4]), 2); // Act transportRoute.AddTransitStateToNotification(secondTransitState); // Assert Assert.Equal(3, transportRoute.TransitStates.Count()); var actualStates = transportRoute.TransitStates.GetEnumerator(); actualStates.MoveNext(); Assert.Equal(1, actualStates.Current.OrdinalPosition); actualStates.MoveNext(); Assert.Equal(2, actualStates.Current.OrdinalPosition); actualStates.MoveNext(); Assert.Equal(3, actualStates.Current.OrdinalPosition); }
public void CreateManyAccounts(int count) { ManagedSecurityContext sec = ManagedAccount.GetAdminSecurityContext(Session); TransitCountry tc = new TransitCountry(); tc.Name = Guid.NewGuid().ToString(); TransitState ts = new TransitState(); ts.Name = Guid.NewGuid().ToString(); ts.Country = tc.Name; ManagedCountry c = new ManagedCountry(Session); c.CreateOrUpdate(tc, sec); ManagedState s = new ManagedState(Session); s.CreateOrUpdate(ts, sec); TransitAccountAddress ta = new TransitAccountAddress(); ta.Apt = "123"; ta.City = "New York"; ta.Country = tc.Name; ta.Name = "My Address"; ta.State = ts.Name; ta.Street = "Houston St."; ta.Zip = "10001"; for (int i = 0; i < count; i++) { ManagedAccount a = new ManagedAccount(Session); string name = Guid.NewGuid().ToString(); a.Create( name, "password", string.Format("{0}@localhost.com", name), DateTime.UtcNow, sec); ManagedAccountAddress ma = new ManagedAccountAddress(Session); ma.CreateOrUpdate(ta, a.GetSecurityContext()); } }
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 void CreateAccountAddress() { ManagedAccount a = new ManagedAccount(Session); ManagedCountry c = new ManagedCountry(Session); ManagedState s = new ManagedState(Session); try { a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext); TransitCountry tc = new TransitCountry(); tc.Name = GetNewString(); TransitState ts = new TransitState(); ts.Name = GetNewString(); ts.Country = tc.Name; c.CreateOrUpdate(tc, AdminSecurityContext); s.CreateOrUpdate(ts, AdminSecurityContext); TransitAccountAddress ta = new TransitAccountAddress(); ta.Apt = "123"; ta.City = "New York"; ta.Country = tc.Name; ta.Name = "My Address"; ta.State = ts.Name; ta.Street = "Houston St."; ta.Zip = "10001"; ManagedAccountAddress m_a = new ManagedAccountAddress(Session); m_a.CreateOrUpdate(ta, new ManagedSecurityContext(a.Instance)); } finally { a.Delete(AdminSecurityContext); s.Delete(AdminSecurityContext); c.Delete(AdminSecurityContext); Session.Flush(); } }
public void CreateAccountAddress() { ManagedAccount a = new ManagedAccount(Session); ManagedCountry c = new ManagedCountry(Session); ManagedState s = new ManagedState(Session); try { a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext); TransitCountry tc = new TransitCountry(); tc.Name = GetNewString(); TransitState ts = new TransitState(); ts.Name = GetNewString(); ts.Country = tc.Name; c.CreateOrUpdate(tc, AdminSecurityContext); s.CreateOrUpdate(ts, AdminSecurityContext); TransitAccountAddress ta = new TransitAccountAddress(); ta.Apt = "123"; ta.City = "New York"; ta.Country = tc.Name; ta.Name = "My Address"; ta.State = ts.Name; ta.Street = "Houston St."; ta.Zip = "10001"; ManagedAccountAddress m_a = new ManagedAccountAddress(Session); m_a.CreateOrUpdate(ta, new ManagedSecurityContext(a.Instance)); } finally { a.Delete(AdminSecurityContext); s.Delete(AdminSecurityContext); c.Delete(AdminSecurityContext); Session.Flush(); } }
public void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute(); sitemapdata.Add(new SiteMapDataAttributeNode("System Preferences", Request, "SystemPreferencesManage.aspx")); sitemapdata.Add(new SiteMapDataAttributeNode("States", Request, "SystemStatesManage.aspx")); DomainClass cs = SessionManager.GetDomainClass("State"); inputName.MaxLength = cs["Name"].MaxLengthInChars; int id = RequestId; string defaultcountry = SessionManager.GetCachedConfiguration("SnCore.Country.Default", "United States"); inputCountry.DataSource = SessionManager.GetCollection <TransitCountry, string>( defaultcountry, (ServiceQueryOptions)null, SessionManager.LocationService.GetCountriesWithDefault); inputCountry.DataBind(); if (id > 0) { TransitState tw = SessionManager.LocationService.GetStateById( SessionManager.Ticket, id); inputName.Text = Renderer.Render(tw.Name); ListItemManager.TrySelect(inputCountry, tw.Country); sitemapdata.Add(new SiteMapDataAttributeNode(tw.Name, Request.Url)); } else { sitemapdata.Add(new SiteMapDataAttributeNode("New State", Request.Url)); } StackSiteMap(sitemapdata); } SetDefaultButton(manageAdd); }
public int CreateOrUpdateState(string ticket, TransitState state) { return(WebServiceImpl <TransitState, ManagedState, State> .CreateOrUpdate( ticket, state)); }
public void CanCreateTransitState() { var transitState = new TransitState(anyGuid, anyGuid, anyGuid, anyGuid, 1); Assert.IsType<TransitState>(transitState); }
public void CreatePlace() { ManagedPlaceType type = new ManagedPlaceType(Session); ManagedCountry c = new ManagedCountry(Session); ManagedState t = new ManagedState(Session); ManagedCity s = new ManagedCity(Session); ManagedAccount a = new ManagedAccount(Session); try { a.Create("Test User", "testpassword", "*****@*****.**", DateTime.UtcNow, AdminSecurityContext); a.VerifyAllEmails(); a.AddDefaultPicture(); TransitCountry tc = new TransitCountry(); tc.Name = GetNewString(); TransitState tt = new TransitState(); tt.Name = GetNewString(); tt.Country = tc.Name; TransitCity ts = new TransitCity(); ts.Name = GetNewString(); ts.Country = tc.Name; ts.State = tt.Name; c.CreateOrUpdate(tc, AdminSecurityContext); t.CreateOrUpdate(tt, AdminSecurityContext); s.CreateOrUpdate(ts, AdminSecurityContext); TransitPlaceType t_type = new TransitPlaceType(); t_type.Name = GetNewString(); type.CreateOrUpdate(t_type, AdminSecurityContext); TransitPlace t_place = new TransitPlace(); t_place.Name = GetNewString(); t_place.Type = t_type.Name; t_place.City = ts.Name; t_place.Country = tc.Name; t_place.State = tt.Name; t_place.AccountId = a.Id; ManagedPlace m_place = new ManagedPlace(Session); m_place.CreateOrUpdate(t_place, a.GetSecurityContext()); } finally { try { a.Delete(AdminSecurityContext); type.Delete(AdminSecurityContext); s.Delete(AdminSecurityContext); t.Delete(AdminSecurityContext); c.Delete(AdminSecurityContext); } catch { } } }
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); transportRoute.SetStateOfImportForNotification( new StateOfImport( importCountry, new TestableCompetentAuthority() { Country = importCountry }, new TestableEntryOrExitPoint() { Country = importCountry })); transportRoute.SetStateOfExportForNotification(new StateOfExport( exportCountry, new TestableCompetentAuthority() { Country = exportCountry }, new TestableEntryOrExitPoint() { Country = exportCountry })); transportRoute.AddTransitStateToNotification(transitState); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("entry", "entry", importCountry)); transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("exit", "exit", exportCountry)); transportRoute.RemoveTransitState(transitStateId); Assert.Equal(transportRoute, transportRoute.Events.OfType<AllTransitStatesInEUEvent>().SingleOrDefault().TransportRoute); }
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); }
private TransitState GenerateTransitState(Draft.TransitState transitState, TransportRouteLookups lookups) { var returnValue = new TransitState(); if (transitState.CompetentAuthorityId.HasValue) { var competentAuthority = lookups.GetCompetentAuthority(transitState.CompetentAuthorityId); returnValue.CompetentAuthorityCode = competentAuthority.Code; returnValue.CompetentAuthorityName = competentAuthority.Name; } if (transitState.CountryId.HasValue) { returnValue.CountryName = lookups.GetCountry(transitState.CountryId).Name; } if (transitState.EntryPointId.HasValue) { returnValue.EntryPointName = lookups.GetEntryOrExitPoint(transitState.EntryPointId).Name; } if (transitState.ExitPointId.HasValue) { returnValue.ExitPointName = lookups.GetEntryOrExitPoint(transitState.ExitPointId).Name; } return returnValue; }
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 ImportAndExportInEU_EditTransitStateFromNonEUToEU_RaisesAllTransitStatesInEUEvent() { transportRoute.RemoveTransitState(FirstTransitStateId); transportRoute.RemoveTransitState(ThirdTransitStateId); transportRoute.RemoveTransitState(SecondTransitStateId); transportRoute.ClearEvents(); 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 transitCountryEu = CountryFactory.Create(new Guid("5B357BA4-B9E9-4325-AD26-DE7662F81FA6")); transportRoute.SetStateOfImportForNotification( new StateOfImport( importCountry, new TestableCompetentAuthority() { Country = importCountry }, new TestableEntryOrExitPoint() { Country = importCountry })); transportRoute.SetStateOfExportForNotification(new StateOfExport( exportCountry, new TestableCompetentAuthority() { Country = exportCountry }, new TestableEntryOrExitPoint() { Country = exportCountry })); var transitState = new TransitState( transitCountry, new TestableCompetentAuthority() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, 1); var transitStateId = new Guid("0BE78BE8-F666-4775-B3DA-7C058BFE4F4D"); EntityHelper.SetEntityId(transitState, transitStateId); transportRoute.AddTransitStateToNotification(transitState); transportRoute.SetEntryCustomsOffice(new EntryCustomsOffice("entry", "entry", importCountry)); transportRoute.SetExitCustomsOffice(new ExitCustomsOffice("exit", "exit", exportCountry)); transportRoute.UpdateTransitStateForNotification(transitStateId, transitCountryEu, new TestableCompetentAuthority() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, new TestableEntryOrExitPoint() { Country = transitCountry }, 1); Assert.Equal(transportRoute, transportRoute.Events.OfType<AllTransitStatesInEUEvent>().SingleOrDefault().TransportRoute); }
public void TransitState_EntryAndExitPointTheSame_Succeeds() { var country = countries[0]; var entryPoint = GetTestEntryOrExitPoint(country, new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54")); var exitPoint = GetTestEntryOrExitPoint(country, new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54")); var transitState = new TransitState(country, GetTestCompetentAuthority(country), entryPoint, exitPoint, 1); Assert.Equal(new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54"), transitState.EntryPoint.Id); Assert.Equal(new Guid("E0B04105-8E22-49E6-A00C-CBD2F2D11B54"), transitState.ExitPoint.Id); }
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 AddTransitState_OnlyTransitState_AddedSuccessfully() { var country = countries[1]; var transitState = new TransitState(country, GetTestCompetentAuthority(country), GetTestEntryOrExitPoint(country, Guid.Empty), GetTestEntryOrExitPoint(country, new Guid("E8E2D79A-F1CA-4928-9ED8-AAF961E2B7B7")), 1); transportRoute.AddTransitStateToNotification(transitState); Assert.True(transportRoute.TransitStates.Count() == 1); }
private static TransitState TransitState(Country country, string name) { var ca = CompetentAuthorityFactory.Create(Guid.Empty, country); var state = new TransitState(country, ca, EntryOrExitPointFactory.Create(Guid.Empty, country, name), EntryOrExitPointFactory.Create(Guid.NewGuid(), country, name), 1); return state; }
public void AddTransitState_ToPositionOutOfRange_Throws() { var firstTransitState = new TransitState(countries[0], GetTestCompetentAuthority(countries[0]), GetTestEntryOrExitPoint(countries[0], guids[1]), GetTestEntryOrExitPoint(countries[0], guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var thirdTransitState = new TransitState(countries[1], GetTestCompetentAuthority(countries[1]), GetTestEntryOrExitPoint(countries[1], guids[3]), GetTestEntryOrExitPoint(countries[1], guids[4]), 3); Assert.Throws<InvalidOperationException>(() => transportRoute.AddTransitStateToNotification(thirdTransitState)); }
public void AddTransitState_ToThirdPosition_AddsToNotification() { var firstCountry = countries[0]; var secondCountry = countries[1]; var thirdCountry = countries[2]; var firstTransitState = new TransitState(firstCountry, GetTestCompetentAuthority(firstCountry), GetTestEntryOrExitPoint(firstCountry, guids[1]), GetTestEntryOrExitPoint(firstCountry, guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var secondTransitState = new TransitState(secondCountry, GetTestCompetentAuthority(secondCountry), GetTestEntryOrExitPoint(secondCountry, guids[3]), GetTestEntryOrExitPoint(secondCountry, guids[4]), 2); transportRoute.AddTransitStateToNotification(secondTransitState); var thirdTransitState = new TransitState(thirdCountry, GetTestCompetentAuthority(thirdCountry), GetTestEntryOrExitPoint(thirdCountry, guids[5]), GetTestEntryOrExitPoint(thirdCountry, guids[6]), 3); transportRoute.AddTransitStateToNotification(thirdTransitState); Assert.Equal(3, transportRoute.TransitStates.Count()); }
public void GetAvailableTransitStatePositions_WhereNotificationHasTwoStates_ReturnsThree() { var firstCountry = countries[0]; var secondCountry = countries[1]; var firstTransitState = new TransitState(firstCountry, GetTestCompetentAuthority(firstCountry), GetTestEntryOrExitPoint(firstCountry, guids[1]), GetTestEntryOrExitPoint(firstCountry, guids[2]), 1); transportRoute.AddTransitStateToNotification(firstTransitState); var secondTransitState = new TransitState(secondCountry, GetTestCompetentAuthority(secondCountry), GetTestEntryOrExitPoint(secondCountry, guids[3]), GetTestEntryOrExitPoint(secondCountry, guids[4]), 2); transportRoute.AddTransitStateToNotification(secondTransitState); int[] result = transportRoute.GetAvailableTransitStatePositions(); Assert.Equal(3, result[0]); }
public int CreateOrUpdateState(string ticket, TransitState state) { return WebServiceImpl<TransitState, ManagedState, State>.CreateOrUpdate( ticket, state); }
public void CanCreateTransitState() { var transitState = new TransitState(anyGuid, anyGuid, anyGuid, anyGuid, 1); Assert.IsType <TransitState>(transitState); }