本文整理汇总了C#中TrackingId类的典型用法代码示例。如果您正苦于以下问题:C# TrackingId类的具体用法?C# TrackingId怎么用?C# TrackingId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrackingId类属于命名空间,在下文中一共展示了TrackingId类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InspectCargo
public void InspectCargo(TrackingId trackingId)
{
Validate.NotNull(trackingId, "Tracking ID is required");
Cargo cargo;
using (var transactionScope = new TransactionScope())
{
cargo = cargoRepository.Find(trackingId);
if (cargo == null)
{
logger.Warn("Can't inspect non-existing cargo " + trackingId);
return;
}
HandlingHistory handlingHistory = handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId);
cargo.DeriveDeliveryProgress(handlingHistory);
if (cargo.Delivery.IsMisdirected)
{
applicationEvents.CargoWasMisdirected(cargo);
}
if (cargo.Delivery.IsUnloadedAtDestination)
{
applicationEvents.CargoHasArrived(cargo);
}
cargoRepository.Store(cargo);
transactionScope.Complete();
}
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:33,代码来源:CargoInspectionService.cs
示例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");
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:30,代码来源:HandlingEventService.cs
示例3: find
public Cargo find(TrackingId tid)
{
return sessionFactory.GetCurrentSession().
CreateQuery("from Cargo where TrackingId = :tid").
SetParameter("tid", tid).
UniqueResult<Cargo>();
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:7,代码来源:CargoRepositoryNHibernate.cs
示例4: SearchNoExistingCargoTest
public void SearchNoExistingCargoTest()
{
//Arrange
var cargoRepositoryMock = new Mock<ICargoRepository>();
var handlingEventRepositoryMock = new Mock<IHandlingEventRepository>();
var controllerMock = new Mock<CargoTrackingController>(cargoRepositoryMock.Object,
handlingEventRepositoryMock.Object);
var controller = controllerMock.Object;
const string trackingIdStr = "trackId";
var trackingId = new TrackingId(trackingIdStr);
cargoRepositoryMock.Setup(m => m.Find(trackingId)).Returns((Cargo)null).Verifiable();
//Act
var viewModel = controller.Search(new TrackCommand { TrackingId = trackingIdStr })
.GetModel<CargoTrackingViewAdapter>();
//Assert
//Verify expected method calls
cargoRepositoryMock.Verify();
handlingEventRepositoryMock.Verify();
Assert.IsNull(viewModel);
//Verfy if warning message is set to UI
controllerMock.Verify(m => m.SetMessage(It.Is<string>(s => s == CargoTrackingController.UnknownMessageId)), Times.Once());
//Verify that the method is not invoked
handlingEventRepositoryMock.Verify(m => m.LookupHandlingHistoryOfCargo(It.IsAny<TrackingId>()), Times.Never());
}
开发者ID:chandmk,项目名称:esddd,代码行数:27,代码来源:CargoTrackingControllerTest.cs
示例5: 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
示例6: 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
示例7: Ctor_02
public void Ctor_02()
{
// arrange:
System.Collections.Generic.List<object> mocks = new System.Collections.Generic.List<object>();
TrackingId id = new TrackingId("CLAIM");
IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow).Repeat.AtLeastOnce();
mocks.Add(itinerary);
IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
mocks.Add(specification);
IRouteSpecification specification2 = MockRepository.GenerateStrictMock<IRouteSpecification>();
specification2.Expect(s => s.IsSatisfiedBy(itinerary)).Return(false).Repeat.Any();
mocks.Add(specification2);
CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
mocks.Add(previousState);
previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
mocks.Add(previousState);
previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, specification2);
mocks.Add(previousState);
DateTime claimDate = DateTime.UtcNow;
// act:
Assert.Throws<ArgumentException>(delegate { new ClaimedCargo(previousState, claimDate); });
// assert:
foreach(object mock in mocks)
{
mock.VerifyAllExpectations();
}
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:32,代码来源:ClaimedCargoQA.cs
示例8: FindEventsForCargo
public void FindEventsForCargo()
{
var trackingId = new TrackingId("XYZ");
IList<HandlingEvent> handlingEvents =
handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId).DistinctEventsByCompletionTime();
Assert.AreEqual(12, handlingEvents.Count);
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:7,代码来源:HandlingEventRepositoryTest.cs
示例9: assignCargoToRoute
public void assignCargoToRoute(string trackingIdStr, RouteCandidateDTO routeCandidateDTO)
{
var itinerary = DTOAssembler.fromDTO(routeCandidateDTO, voyageRepository, locationRepository);
var trackingId = new TrackingId(trackingIdStr);
bookingService.assignCargoToRoute(itinerary, trackingId);
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:7,代码来源:BookingServiceFacadeImpl.cs
示例10: 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
示例11: NewCargo
public static Cargo NewCargo(TrackingId trackingId, Location origin, Location destination,
DateTime arrivalDeadline)
{
var routeSpecification = new RouteSpecification(origin, destination, arrivalDeadline);
return new Cargo(trackingId, routeSpecification);
}
开发者ID:colourblendcreative,项目名称:ndddsample,代码行数:7,代码来源:CargoFactory.cs
示例12: reportCargoUpdate
public void reportCargoUpdate(TrackingId trackingId)
{
Cargo cargo = cargoRepository.find(trackingId);
CargoDetails cargoDetails = assembleFrom(cargo);
reportSubmission.submitCargoDetails(cargoDetails);
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:7,代码来源:ReportPusher.cs
示例13: setUp
public void setUp()
{
reportSubmission = MockRepository.GenerateMock<ReportSubmission>();
CargoRepository cargoRepository = new CargoRepositoryInMem();
HandlingEventRepository handlingEventRepository = new HandlingEventRepositoryInMem();
HandlingEventFactory handlingEventFactory = new HandlingEventFactory(cargoRepository,
new VoyageRepositoryInMem(),
new LocationRepositoryInMem());
TrackingId trackingId = new TrackingId("ABC");
RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG, L.ROTTERDAM, DateTime.Parse("2009-10-10"));
Cargo cargo = new Cargo(trackingId, routeSpecification);
cargoRepository.store(cargo);
HandlingEvent handlingEvent = handlingEventFactory.createHandlingEvent(
DateTime.Parse("2009-10-02"),
trackingId,
null,
L.HONGKONG.UnLocode,
HandlingActivityType.RECEIVE,
new OperatorCode("ABCDE")
);
handlingEventRepository.store(handlingEvent);
cargo.Handled(handlingEvent.Activity);
reportPusher = new ReportPusher(reportSubmission, cargoRepository, handlingEventRepository);
eventSequenceNumber = handlingEvent.SequenceNumber;
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:29,代码来源:ReportsUpdaterTest.cs
示例14: testCalculatePossibleRoutes
public void testCalculatePossibleRoutes()
{
TrackingId trackingId = new TrackingId("ABC");
RouteSpecification routeSpecification = new RouteSpecification(L.HONGKONG,
L.HELSINKI,
DateTime.Parse("2009-04-01"));
Cargo cargo = new Cargo(trackingId, routeSpecification);
var candidates = externalRoutingService.fetchRoutesForSpecification(routeSpecification);
Assert.NotNull(candidates);
foreach(Itinerary itinerary in candidates)
{
var legs = itinerary.Legs;
Assert.NotNull(legs);
Assert.True(legs.Any());
// Cargo origin and start of first leg should match
Assert.AreEqual(cargo.RouteSpecification.Origin, legs.ElementAt(0).LoadLocation);
// Cargo final destination and last leg stop should match
Location lastLegStop = legs.Last().UnloadLocation;
Assert.AreEqual(cargo.RouteSpecification.Destination, lastLegStop);
for(int i = 0; i < legs.Count() - 1; i++)
{
// Assert that all legs are connected
Assert.AreEqual(legs.ElementAt(i).UnloadLocation, legs.ElementAt(i + 1).LoadLocation);
}
}
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:31,代码来源:ExternalRoutingServiceTest.cs
示例15: Init
public void Init()
{
TrackingId xyz = new TrackingId("XYZ");
Cargo cargoXYZ = createCargoWithDeliveryHistory(
xyz, SampleLocations.STOCKHOLM, SampleLocations.MELBOURNE,
handlingEventRepository.LookupHandlingHistoryOfCargo(xyz));
cargoDb.Add(xyz.IdString, cargoXYZ);
TrackingId zyx = new TrackingId("ZYX");
Cargo cargoZYX = createCargoWithDeliveryHistory(
zyx, SampleLocations.MELBOURNE, SampleLocations.STOCKHOLM,
handlingEventRepository.LookupHandlingHistoryOfCargo(zyx));
cargoDb.Add(zyx.IdString, cargoZYX);
TrackingId abc = new TrackingId("ABC");
Cargo cargoABC = createCargoWithDeliveryHistory(
abc, SampleLocations.STOCKHOLM, SampleLocations.HELSINKI,
handlingEventRepository.LookupHandlingHistoryOfCargo(abc));
cargoDb.Add(abc.IdString, cargoABC);
TrackingId cba = new TrackingId("CBA");
Cargo cargoCBA = createCargoWithDeliveryHistory(
cba, SampleLocations.HELSINKI, SampleLocations.STOCKHOLM,
handlingEventRepository.LookupHandlingHistoryOfCargo(cba));
cargoDb.Add(cba.IdString, cargoCBA);
}
开发者ID:chandmk,项目名称:esddd,代码行数:26,代码来源:CargoRepositoryInMem.cs
示例16: TrackingIdShouldBeValueObject
public void TrackingIdShouldBeValueObject()
{
var trackingId = new TrackingId("XYZ");
Assert.AreEqual(new TrackingId("XYZ"), trackingId);
Assert.AreNotEqual(new TrackingId("ABC"), trackingId);
}
开发者ID:paulrayner,项目名称:dddsample,代码行数:7,代码来源:TrackingIdTests.cs
示例17: Cargo
public Cargo(TrackingId trackingId, RouteSpecification routeSpecification)
{
TrackingId = trackingId;
RouteSpecification = routeSpecification;
TransportStatus = TransportStatus.NotReceived;
RoutingStatus = RoutingStatus.NotRouted;
}
开发者ID:paulrayner,项目名称:dddsample,代码行数:7,代码来源:Cargo.cs
示例18: 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();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:31,代码来源:ClaimedCargoQA.cs
示例19: 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
}
开发者ID:awhatley,项目名称:dddsample.net,代码行数:25,代码来源:HandlingEventRepositoryTest.cs
示例20: 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();
}
开发者ID:hungdluit,项目名称:Epic.NET,代码行数:34,代码来源:InPortCargoQA.cs
注:本文中的TrackingId类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论