本文整理汇总了C#中TrackingId类的典型用法代码示例。如果您正苦于以下问题:C# TrackingId类的具体用法?C# TrackingId怎么用?C# TrackingId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrackingId类属于命名空间,在下文中一共展示了TrackingId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例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 Cargo find(TrackingId tid)
{
return sessionFactory.GetCurrentSession().
CreateQuery("from Cargo where TrackingId = :tid").
SetParameter("tid", tid).
UniqueResult<Cargo>();
}
示例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());
}
示例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();
}
示例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);
}
}
示例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();
}
}
示例8: FindEventsForCargo
public void FindEventsForCargo()
{
var trackingId = new TrackingId("XYZ");
IList<HandlingEvent> handlingEvents =
handlingEventRepository.LookupHandlingHistoryOfCargo(trackingId).DistinctEventsByCompletionTime();
Assert.AreEqual(12, handlingEvents.Count);
}
示例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);
}
示例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();
}
示例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);
}
示例12: reportCargoUpdate
public void reportCargoUpdate(TrackingId trackingId)
{
Cargo cargo = cargoRepository.find(trackingId);
CargoDetails cargoDetails = assembleFrom(cargo);
reportSubmission.submitCargoDetails(cargoDetails);
}
示例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;
}
示例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);
}
}
}
示例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);
}