本文整理汇总了C#中UnLocode类的典型用法代码示例。如果您正苦于以下问题:C# UnLocode类的具体用法?C# UnLocode怎么用?C# UnLocode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnLocode类属于命名空间,在下文中一共展示了UnLocode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Append_03
public void Append_03()
{
// arrange:
UnLocode c1 = new UnLocode("LOCDA");
UnLocode c2 = new UnLocode("LOCDA");
ICarrierMovement m1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
m1.Expect(m => m.ArrivalLocation).Return(c1).Repeat.Any();
m1.Expect(m => m.ArrivalTime).Return(DateTime.UtcNow + new TimeSpan(48, 0, 0)).Repeat.Any();
ICarrierMovement m2 = MockRepository.GenerateStrictMock<ICarrierMovement>();
m2.Expect(m => m.DepartureLocation).Return(c2).Repeat.Any();
m2.Expect(m => m.DepartureTime).Return(DateTime.UtcNow + new TimeSpan(72, 0, 0)).Repeat.Any();
ISchedule empty = new Schedule();
ISchedule schedule1 = empty.Append(m1);
// act:
ISchedule schedule2 = schedule1.Append(m2);
// assert:
Assert.IsFalse(schedule2.Equals(empty));
Assert.IsFalse(schedule2.Equals(schedule1));
Assert.AreSame(m1, schedule2[0]);
Assert.AreSame(m2, schedule2[1]);
Assert.AreEqual(2, schedule2.Count());
Assert.AreEqual(2, schedule2.MovementsCount);
m1.VerifyAllExpectations();
m2.VerifyAllExpectations();
}
示例2: RegisterHandlingEvent
public void RegisterHandlingEvent(DateTime completionTime,
TrackingId trackingId,
VoyageNumber voyageNumber,
UnLocode unLocode,
HandlingType type)
{
//TODO: Revise transaciton and UoW logic
using (var transactionScope = new TransactionScope())
{
var registrationTime = new DateTime();
/* Using a factory to create a HandlingEvent (aggregate). This is where
it is determined wether the incoming data, the attempt, actually is capable
of representing a real handling event. */
HandlingEvent evnt = handlingEventFactory.CreateHandlingEvent(
registrationTime, completionTime, trackingId, voyageNumber, unLocode, type);
/* Store the new handling event, which updates the persistent
state of the handling event aggregate (but not the cargo aggregate -
that happens asynchronously!)*/
handlingEventRepository.Store(evnt);
/* Publish an event stating that a cargo has been handled. */
applicationEvents.CargoWasHandled(evnt);
transactionScope.Complete();
}
logger.Info("Registered handling event");
}
示例3: find
public Location find(UnLocode unLocode)
{
return sessionFactory.GetCurrentSession().
CreateQuery("from Location where UnLocode = ?").
SetParameter(0, unLocode).
UniqueResult<Location>();
}
示例4: Ctor_withValidArgs_works
public void Ctor_withValidArgs_works(EventType type)
{
// arrange:
List<object> mocks = new List<object>();
Username userId = new Username("Giacomo");
IUser user = MockRepository.GenerateStrictMock<IUser>();
user.Expect(u => u.Username).Return(userId).Repeat.Once();
mocks.Add(user);
TrackingId cargoId = new TrackingId("CARGO001");
UnLocode location = new UnLocode("UNLOC");
VoyageNumber voyage = new VoyageNumber("VYG001");
ICargo cargo = MockRepository.GenerateStrictMock<ICargo>();
cargo.Expect(c => c.TrackingId).Return(cargoId).Repeat.Once();
IDelivery delivery = MockRepository.GenerateStrictMock<IDelivery>();
delivery.Expect(d => d.LastKnownLocation).Return(location).Repeat.Once();
delivery.Expect(d => d.CurrentVoyage).Return(voyage).Repeat.Once();
mocks.Add(delivery);
cargo.Expect(c => c.Delivery).Return(delivery).Repeat.Twice();
mocks.Add(cargo);
DateTime completionDate = DateTime.UtcNow;
// act:
IEvent underTest = new Event(user, cargo, type, completionDate);
// assert:
Assert.AreSame(userId, underTest.User);
Assert.AreSame(cargoId, underTest.Cargo);
Assert.AreSame(location, underTest.Location);
Assert.AreSame(voyage, underTest.Voyage);
Assert.AreEqual(completionDate, underTest.Date);
Assert.AreEqual(type, underTest.Type);
foreach(object mock in mocks)
mock.VerifyAllExpectations();
}
示例5: Leg
public Leg (IVoyage voyage, ILocation loadLocation, DateTime loadTime, ILocation unloadLocation, DateTime unloadTime)
{
if(null == voyage)
throw new ArgumentNullException("voyage");
if(null == loadLocation)
throw new ArgumentNullException("loadLocation");
if(null == unloadLocation)
throw new ArgumentNullException("unloadLocation");
if(loadTime >= unloadTime)
throw new ArgumentException("Unload time must follow the load time.","unloadTime");
if(loadLocation.UnLocode.Equals(unloadLocation.UnLocode))
throw new ArgumentException("The locations must not be differents.", "unloadLocation");
if(!voyage.WillStopOverAt(loadLocation))
{
string message = string.Format("The voyage {0} will not stop over the load location {1}.", voyage.Number, loadLocation.UnLocode);
throw new ArgumentException(message, "loadLocation");
}
if(!voyage.WillStopOverAt(unloadLocation))
{
string message = string.Format("The voyage {0} will not stop over the unload location {1}.", voyage.Number, unloadLocation.UnLocode);
throw new ArgumentException(message, "unloadLocation");
}
_voyage = voyage.Number;
_loadLocation = loadLocation.UnLocode;
_unloadLocation = unloadLocation.UnLocode;
_loadTime = loadTime;
_unloadTime = unloadTime;
}
示例6: Ctor_01
public void Ctor_01()
{
// arrange:
GList mocks = new GList();
TrackingId id = new TrackingId("START");
DateTime loadTime = DateTime.Now;
VoyageNumber voyageNumber = new VoyageNumber("VYG001");
UnLocode location = new UnLocode("CURLC");
IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
itinerary.Expect(i => i.Equals(null)).IgnoreArguments().Return(false).Repeat.Any();
itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow + TimeSpan.FromDays(1)).Repeat.Any();
itinerary.Expect(i => i.FinalArrivalLocation).Return(new UnLocode("ENDLC")).Repeat.Any();
mocks.Add(itinerary);
IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
mocks.Add(previousState);
previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
mocks.Add(previousState);
IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
voyage.Expect(v => v.LastKnownLocation).Return(location).Repeat.AtLeastOnce();
mocks.Add(voyage);
// act:
CargoState state = new OnboardCarrierCargo(previousState, voyage, loadTime);
// assert:
Assert.IsNotNull(state);
Assert.AreSame(voyageNumber, state.CurrentVoyage);
Assert.AreEqual(TransportStatus.OnboardCarrier, state.TransportStatus);
Assert.AreSame(location, state.LastKnownLocation);
foreach(object mock in mocks)
mock.VerifyAllExpectations();
}
示例7: Append_01
public void Append_01()
{
// arrange:
UnLocode loc1 = new UnLocode("CODLD");
UnLocode loc2 = new UnLocode("CODUN");
DateTime arrivalDate = DateTime.UtcNow + TimeSpan.FromDays(10);
ILeg leg = MockRepository.GenerateStrictMock<ILeg>();
leg.Expect(l => l.LoadLocation).Return(loc1).Repeat.Once();
leg.Expect(l => l.UnloadLocation).Return(loc2).Repeat.Once();
leg.Expect(l => l.UnloadTime).Return(arrivalDate).Repeat.Once();
Itinerary empty = new Itinerary();
// act:
IItinerary tested = empty.Append(leg);
// assert:
Assert.IsNotNull(tested);
Assert.AreEqual(1, tested.Count());
Assert.AreSame(leg, tested.First());
Assert.AreSame(leg, tested.Last());
Assert.AreEqual(loc1, tested.InitialDepartureLocation);
Assert.AreEqual(loc2, tested.FinalArrivalLocation);
Assert.AreEqual(arrivalDate, tested.FinalArrivalDate);
leg.VerifyAllExpectations();
}
示例8: Ctor_02
public void Ctor_02()
{
// arrange:
List<object> mocks = new List<object>();
UnLocode code = new UnLocode("START");
DateTime arrival = DateTime.UtcNow;
TrackingId id = new TrackingId("CARGO01");
IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
itinerary.Expect(i => i.Equals(null)).IgnoreArguments().Return(false).Repeat.Any();
itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow + TimeSpan.FromDays(1)).Repeat.Any();
itinerary.Expect(i => i.FinalArrivalLocation).Return(code).Repeat.Any();
mocks.Add(itinerary);
IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
mocks.Add(specification);
CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
mocks.Add(previousState);
previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
mocks.Add(previousState);
previousState.Expect(s => s.LastKnownLocation).Return(code).Repeat.Any();
// act:
InPortCargo state = new InPortCargo(previousState, code, arrival);
// assert:
Assert.IsTrue(TransportStatus.InPort == state.TransportStatus);
Assert.IsNull(state.CurrentVoyage);
Assert.AreSame(code, state.LastKnownLocation);
Assert.IsTrue(state.IsUnloadedAtDestination);
Assert.AreSame(id, state.Identifier);
foreach (object mock in mocks)
mock.VerifyAllExpectations();
}
示例9: testSave
public void testSave()
{
var unLocode = new UnLocode("SESTO");
var trackingId = new TrackingId("XYZ");
var completionTime = DateTime.Parse("2008-01-01");
HandlingEvent @event = HandlingEventFactory.createHandlingEvent(completionTime,
trackingId,
null,
unLocode,
HandlingActivityType.CLAIM,
null);
HandlingEventRepository.store(@event);
flush();
var result = GenericTemplate.QueryForObjectDelegate(CommandType.Text,
String.Format("select * from HandlingEvent where sequence_number = {0}", @event.SequenceNumber),
(r, i) => new {CARGO_ID = r["CARGO_ID"], COMPLETIONTIME = r["COMPLETIONTIME"]});
Assert.AreEqual(1L, result.CARGO_ID);
Assert.AreEqual(completionTime, result.COMPLETIONTIME);
// TODO: the rest of the columns
}
示例10: Ctor_01
public void Ctor_01()
{
// arrange:
UnLocode final = new UnLocode("FINAL");
TrackingId id = new TrackingId("CLAIM");
IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow).Repeat.AtLeastOnce();
itinerary.Expect(i => i.FinalArrivalLocation).Return(final).Repeat.AtLeastOnce();
IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
previousState.Expect(s => s.IsUnloadedAtDestination).Return(true).Repeat.AtLeastOnce();
previousState.Expect(s => s.TransportStatus).Return(TransportStatus.InPort).Repeat.AtLeastOnce();
DateTime claimDate = DateTime.UtcNow;
// act:
ClaimedCargo state = new ClaimedCargo(previousState, claimDate);
// assert:
Assert.AreEqual(TransportStatus.Claimed, state.TransportStatus);
Assert.AreEqual(RoutingStatus.Routed, state.RoutingStatus);
Assert.AreSame(final, state.LastKnownLocation);
Assert.AreSame(specification, state.RouteSpecification);
Assert.IsNull(state.CurrentVoyage);
Assert.IsTrue(state.IsUnloadedAtDestination);
itinerary.VerifyAllExpectations();
specification.VerifyAllExpectations();
previousState.VerifyAllExpectations();
}
示例11: createHandlingEvent
/// <summary>
/// Creates a handling event.
/// </summary>
/// <param name="completionTime">when the event was completed, for example finished loading</param>
/// <param name="trackingId">cargo tracking id</param>
/// <param name="voyageNumber">voyage number</param>
/// <param name="unlocode">United Nations Location Code for the location of the event</param>
/// <param name="type">type of event</param>
/// <param name="operatorCode">operator code</param>
/// <returns>A handling event.</returns>
/// <exception cref="UnknownVoyageException">if there's no voyage with this number</exception>
/// <exception cref="UnknownCargoException">if there's no cargo with this tracking id</exception>
/// <exception cref="UnknownLocationException">if there's no location with this UN Locode</exception>
public HandlingEvent createHandlingEvent(DateTime completionTime, TrackingId trackingId,
VoyageNumber voyageNumber, UnLocode unlocode,
HandlingActivityType type, OperatorCode operatorCode)
{
var cargo = findCargo(trackingId);
var voyage = findVoyage(voyageNumber);
var location = findLocation(unlocode);
try
{
var registrationTime = DateTime.Now;
if(voyage == null)
{
return new HandlingEvent(cargo, completionTime, registrationTime, type, location);
}
else
{
return new HandlingEvent(cargo, completionTime, registrationTime, type, location, voyage, operatorCode);
}
}
catch(Exception e)
{
throw new CannotCreateHandlingEventException(e.Message, e);
}
}
示例12: TestHashCode
public void TestHashCode()
{
var allCaps = new UnLocode("ABCDE");
var mixedCase = new UnLocode("aBcDe");
Assert.AreEqual(allCaps.GetHashCode(), mixedCase.GetHashCode());
}
示例13: Ctor_withNullDestination_throwsArgumentNullException
public void Ctor_withNullDestination_throwsArgumentNullException ()
{
// arrange:
UnLocode previous = new UnLocode("CDPRV");
// act:
new VoyageEventArgs(previous, null);
}
示例14: Ctor_withEmptyName_throwsArgumentNullException
public void Ctor_withEmptyName_throwsArgumentNullException ()
{
// arrange:
UnLocode code = new UnLocode("UNLOC");
// act:
Assert.Throws<ArgumentNullException>(delegate{ new Challenge00.DDDSample.Location.Location(code, string.Empty); });
}
示例15: ChangeDestination
public void ChangeDestination(TrackingId trackingId, UnLocode destinationUnLocode)
{
Cargo cargo = _cargoRepository.Find(trackingId);
Location destination = _locationRepository.Find(destinationUnLocode);
RouteSpecification routeSpecification = new RouteSpecification(cargo.RouteSpecification.Origin, destination, cargo.RouteSpecification.ArrivalDeadline);
cargo.SpecifyNewRoute(routeSpecification);
}