本文整理汇总了C#中VoyageNumber类的典型用法代码示例。如果您正苦于以下问题:C# VoyageNumber类的具体用法?C# VoyageNumber怎么用?C# VoyageNumber使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VoyageNumber类属于命名空间,在下文中一共展示了VoyageNumber类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:35,代码来源:OnboardCarrierCargoQA.cs
示例2: 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);
}
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:38,代码来源:HandlingEventFactory.cs
示例3: 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");
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:30,代码来源:HandlingEventService.cs
示例4: find
public Voyage find(VoyageNumber voyageNumber)
{
return sessionFactory.GetCurrentSession().
CreateQuery("from Voyage where VoyageNumber = :vn").
SetParameter("vn", voyageNumber).
UniqueResult<Voyage>();
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:7,代码来源:VoyageRepositoryNHibernate.cs
示例5: MovingVoyage
public MovingVoyage (VoyageNumber number, ISchedule schedule, int movementIndex)
: base(number, schedule)
{
if(movementIndex < 0 || movementIndex >= schedule.MovementsCount)
throw new ArgumentOutOfRangeException("movementIndex");
_movementIndex = movementIndex;
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:7,代码来源:MovingVoyage.cs
示例6: 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();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:34,代码来源:EventQA.cs
示例7: Ctor_02
public void Ctor_02 ()
{
// arrange:
VoyageNumber number = new VoyageNumber("VYGTEST01");
// act:
new CompletedVoyage(number, null);
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:8,代码来源:CompletedVoyageQA.cs
示例8: Ctor_02
public void Ctor_02 ()
{
// arrange:
VoyageNumber number = new VoyageNumber("VYGTEST01");
// act:
new MovingVoyage(number, null, 0);
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:8,代码来源:MovingVoyageQA.cs
示例9: Ctor_03
public void Ctor_03(int index)
{
// arrange:
VoyageNumber number = new VoyageNumber("VYGTEST01");
ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
// act:
new MovingVoyage(number, schedule, index);
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:10,代码来源:MovingVoyageQA.cs
示例10: updateItineraries
public void updateItineraries(VoyageNumber voyageNumber)
{
var voyage = voyageRepository.find(voyageNumber);
var affectedCargos = cargoRepository.findCargosOnVoyage(voyage);
foreach(Cargo cargo in affectedCargos)
{
var newItinerary = cargo.Itinerary.WithRescheduledVoyage(voyage);
cargo.AssignToRoute(newItinerary);
LOG.Info("Updated itinerary of cargo " + cargo);
}
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:12,代码来源:ItineraryUpdater.cs
示例11: HandlingEventRegistrationAttempt
public HandlingEventRegistrationAttempt(DateTime registrationDate,
DateTime completionDate,
TrackingId trackingId,
VoyageNumber voyageNumber,
HandlingType type,
UnLocode unLocode)
{
registrationTime = registrationDate;
completionTime = completionDate;
this.trackingId = trackingId;
this.voyageNumber = voyageNumber;
this.type = type;
this.unLocode = unLocode;
}
开发者ID:chandmk,项目名称:esddd,代码行数:14,代码来源:HandlingEventRegistrationAttempt.cs
示例12: Ctor_01
public void Ctor_01()
{
// arrange:
VoyageNumber number = new VoyageNumber("VYGTEST01");
ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
// act:
CompletedVoyage state = new CompletedVoyage(number, schedule);
// assert:
Assert.AreSame(schedule, state.Schedule);
Assert.IsFalse(state.IsMoving);
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:14,代码来源:CompletedVoyageQA.cs
示例13: findVoyage
private Voyage findVoyage(VoyageNumber voyageNumber)
{
if(voyageNumber == null)
{
return null;
}
var voyage = voyageRepository.find(voyageNumber);
if(voyage == null)
{
throw new UnknownVoyageException(voyageNumber);
}
return voyage;
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:15,代码来源:HandlingEventFactory.cs
示例14: fromDTO
internal static Itinerary fromDTO(RouteCandidateDTO routeCandidateDTO,
VoyageRepository voyageRepository,
LocationRepository locationRepository)
{
var legs = new List<Leg>(routeCandidateDTO.getLegs().Count());
foreach(LegDTO legDTO in routeCandidateDTO.getLegs())
{
var voyageNumber = new VoyageNumber(legDTO.getVoyageNumber());
var voyage = voyageRepository.find(voyageNumber);
var from = locationRepository.find(new UnLocode(legDTO.getFrom()));
var to = locationRepository.find(new UnLocode(legDTO.getTo()));
legs.Add(Leg.DeriveLeg(voyage, from, to));
}
return new Itinerary(legs);
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:15,代码来源:DTOAssembler.cs
示例15: TestCreateHandlingEventUnknownCarrierMovement
public void TestCreateHandlingEventUnknownCarrierMovement()
{
cargoRepositoryMock.Setup(rep => rep.Find(trackingId)).Returns(cargo);
try
{
var invalid = new VoyageNumber("XXX");
DateTime completionTime = DateTime.Now.AddDays(10);
factory.CreateHandlingEvent(
DateTime.Now, completionTime, trackingId, invalid, SampleLocations.STOCKHOLM.UnLocode,
HandlingType.LOAD
);
Assert.Fail("Expected UnknownVoyageException");
}
catch (UnknownVoyageException expected) {}
}
开发者ID:chandmk,项目名称:esddd,代码行数:16,代码来源:HandlingEventFactoryTest.cs
示例16: FromDTO
/// <summary>
/// Assemble a Itinerary from provided RouteCandidateDTO.
/// </summary>
/// <param name="routeCandidateDTO">route candidate DTO</param>
/// <param name="voyageRepository">voyage repository</param>
/// <param name="locationRepository">location repository</param>
/// <returns>An itinerary</returns>
public Itinerary FromDTO(RouteCandidateDTO routeCandidateDTO,
IVoyageRepository voyageRepository,
ILocationRepository locationRepository)
{
var legs = new List<Leg>(routeCandidateDTO.Legs.Count);
foreach (LegDTO legDTO in routeCandidateDTO.Legs)
{
VoyageNumber voyageNumber = new VoyageNumber(legDTO.VoyageNumber);
Voyage voyage = voyageRepository.Find(voyageNumber);
Location from = locationRepository.Find(new UnLocode(legDTO.FromLocation));
Location to = locationRepository.Find(new UnLocode(legDTO.ToLocation));
legs.Add(new Leg(voyage, from, to, legDTO.LoadTime, legDTO.UnloadTime));
}
return new Itinerary(legs);
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:24,代码来源:ItineraryCandidateDTOAssembler.cs
示例17: Voyage_LiveCycle_01
public void Voyage_LiveCycle_01 ()
{
// arrange:
UnLocode code1 = new UnLocode("CODAA");
ILocation loc1 = MockRepository.GenerateStrictMock<ILocation>();
loc1.Expect(l => l.UnLocode).Return(code1).Repeat.Any();
loc1.Expect(l => l.Name).Return("First location").Repeat.Any();
UnLocode code2 = new UnLocode("CODAB");
ILocation loc2 = MockRepository.GenerateStrictMock<ILocation>();
loc2.Expect(l => l.UnLocode).Return(code2).Repeat.Any();
loc2.Expect(l => l.Name).Return("Second location").Repeat.Any();
UnLocode code3 = new UnLocode("CODAC");
ILocation loc3 = MockRepository.GenerateStrictMock<ILocation>();
loc3.Expect(l => l.UnLocode).Return(code3).Repeat.Any();
loc3.Expect(l => l.Name).Return("Third location").Repeat.Any();
ISchedule schedule = new Schedule();
schedule = schedule.Append(new CarrierMovement(loc1, DateTime.UtcNow, loc2, DateTime.UtcNow + TimeSpan.FromDays(2)));
schedule = schedule.Append(new CarrierMovement(loc2, DateTime.UtcNow + TimeSpan.FromDays(3), loc3, DateTime.UtcNow + TimeSpan.FromDays(4)));
VoyageNumber number = new VoyageNumber("TESTVYG");
VoyageEventArgs departedEvent = null;
VoyageEventArgs stoppedEvent = null;
// act:
Challenge00.DDDSample.Voyage.Voyage voyage = new Challenge00.DDDSample.Voyage.Voyage(number, schedule);
voyage.Departed += delegate(object sender, VoyageEventArgs e) {
departedEvent = e;
};
voyage.Stopped += delegate(object sender, VoyageEventArgs e) {
stoppedEvent = e;
};
// assert:
Assert.AreSame(number, voyage.Number);
Assert.IsFalse(voyage.IsMoving);
Assert.AreEqual(code1, voyage.LastKnownLocation);
Assert.AreEqual(code2, voyage.NextExpectedLocation);
Assert.IsNull(departedEvent);
Assert.IsNull(stoppedEvent);
loc1.VerifyAllExpectations();
loc2.VerifyAllExpectations();
loc3.VerifyAllExpectations();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:44,代码来源:IntegrationTests.cs
示例18: LastKnownLocation_01
public void LastKnownLocation_01()
{
// arrange:
VoyageNumber number = new VoyageNumber("VYGTEST01");
ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
UnLocode arrivalLocation = new UnLocode("ATEND");
ICarrierMovement movement = MockRepository.GenerateStrictMock<ICarrierMovement>();
movement.Expect(m => m.ArrivalLocation).Return(arrivalLocation).Repeat.Once();
schedule.Expect(s => s[2]).Return(movement).Repeat.Once();
// act:
CompletedVoyage state = new CompletedVoyage(number, schedule);
// assert:
Assert.AreSame(arrivalLocation, state.LastKnownLocation);
movement.VerifyAllExpectations();
schedule.VerifyAllExpectations();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:19,代码来源:CompletedVoyageQA.cs
示例19: registerHandlingEvent
public void registerHandlingEvent(DateTime completionTime, TrackingId trackingId,
VoyageNumber voyageNumber, UnLocode unLocode,
HandlingActivityType type, OperatorCode operatorCode)
{
// 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 handlingEvent.
var handlingEvent = handlingEventFactory.createHandlingEvent(
completionTime, trackingId, voyageNumber, unLocode, type, operatorCode
);
// Store the new handling handlingEvent, which updates the persistent
// state of the handling handlingEvent aggregate (but not the cargo aggregate -
// that happens asynchronously!)
handlingEventRepository.store(handlingEvent);
// Publish a system event
systemEvents.notifyOfHandlingEvent(handlingEvent);
LOG.Info("Registered handling event: " + handlingEvent);
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:21,代码来源:HandlingEventServiceImpl.cs
示例20: CreateHandlingEvent
/// <summary>
/// Creates handling event
/// throws UnknownVoyageException if there's no voyage with this number
/// throws UnknownCargoException if there's no cargo with this tracking id
/// throws UnknownLocationException if there's no location with this UN Locode
/// </summary>
/// <param name="registrationTime"> time when this event was received by the system</param>
/// <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>
/// <returns> A handling event.</returns>
public HandlingEvent CreateHandlingEvent(DateTime registrationTime, DateTime completionTime,
TrackingId trackingId, VoyageNumber voyageNumber, UnLocode unlocode,
HandlingType type)
{
Cargo cargo = FindCargo(trackingId);
Voyage voyage = FindVoyage(voyageNumber);
Location location = FindLocation(unlocode);
try
{
if (voyage == null)
{
return new HandlingEvent(cargo, completionTime, registrationTime, type, location);
}
return new HandlingEvent(cargo, completionTime, registrationTime, type, location, voyage);
}
catch (Exception e)
{
throw new CannotCreateHandlingEventException(e);
}
}
开发者ID:chandmk,项目名称:esddd,代码行数:35,代码来源:HandlingEventFactory.cs
注:本文中的VoyageNumber类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论