public void AddCollectionEventsToShip() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 3 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); var arrivalEvent1 = new ArrivalEvent { Port = new Port { Name = "Roma" }, Version = 1 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent1); var departureEvent = new DepartureEvent { Port = new Port { Name = "Roma" }, Version = 2 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent); Assert.AreEqual("Barcelona", aggreate.Root.Port.Name); }
public void RecordTracking(EventProcessor <ShippingEvent> eProc) { // Create event depending on TrackingType Port OldLocation = TrackedShip.Location; ShippingEvent ev; if (TrackingType == TrackingType.Arrival) { ev = new ArrivalEvent(DateTime.Now, SetPort, TrackedShip, TrackingType); } else { ev = new DepartureEvent(DateTime.Now, SetPort, TrackedShip, TrackingType); } // send the event to the event handler (ship) which will update it's status on the provided event data eProc.ProcessEvent(ev); // notify the UI Tracking List so it can update itself ShipTrackedEventArgs args = new ShipTrackedEventArgs() { TrackingServiceId = TrackingServiceId, Recorded = Recorded, TrackingType = TrackingType, TrackedShip = TrackedShip, OldLocation = OldLocation, NewLocation = SetPort, }; // notify subscribers ... OnShipTracked(args); }
public void SetSail(int hh) { var shipToDepart = new Ship { Port = Port.AT_SEA }; var ev = new DepartureEvent(DateTime.Now, shipToDepart, port); ev.Process(); }
public void CuandoSeAñadeOtroEventoSeGuardaCorrectamente() { var departureEvent = new DepartureEvent { Port = new Port { Name = "Barcelona" } }; _eventsRepositorySql.AddEvent(1, departureEvent); }
public async Task DepartureAsync(string eventId, string shipCode, string portCode) { var port = await serviceProvider.GetService <ISingleQueryPortByIntCode>().UseIntCode(portCode).ExecuteAsync(); var shipQuery = serviceProvider.GetService <ISingleQueryShipByRegCode>().UseRegCode(shipCode); var shipRef = referenceService.GetRef(shipQuery); var @event = new DepartureEvent(DateTime.Now, eventId, shipRef, port); await queueService.AddEvent(@event); }
public void CreateSnapShotAfterApplyEventsShip() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 3 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); var arrivalEvent1 = new ArrivalEvent { Port = new Port { Name = "Roma" }, Version = 1 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent1); var departureEvent = new DepartureEvent { Port = new Port { Name = "Roma" }, Version = 2 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent); var departureEvent1 = new DepartureEvent { Port = new Port { Name = "Barcelona" }, Version = 4 }; var aggregateRoot = _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent1); var arrivalEvent2 = new ArrivalEvent { Port = new Port { Name = "Mallorca" }, Version = 5 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent2).CreateSnapShot(); aggregateRoot.CreateSnapShot(); //Este SnapShot no se deberia guardar var departureEvent2 = new DepartureEvent { Port = new Port { Name = "Mallorca" }, Version = 6 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent2); Assert.AreEqual(Port.AtSea, aggreate.Root.Port); }
public void AddALotOfEventsToShip() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 3 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); var arrivalEvent1 = new ArrivalEvent { Port = new Port { Name = "Roma" }, Version = 1 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent1); var departureEvent = new DepartureEvent { Port = new Port { Name = "Roma" }, Version = 2 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent); var departureEvent1 = new DepartureEvent { Port = new Port { Name = "Barcelona" }, Version = 4 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent1); var arrivalEvent2 = new ArrivalEvent { Port = new Port { Name = "Mallorca" }, Version = 5 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent2); var departureEvent2 = new DepartureEvent { Port = new Port { Name = "Mallorca" }, Version = 6 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent2); Assert.AreEqual(Port.AtSea, aggreate.Root.Port); }
public void ApplyEventToAggreagateRoot() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 3 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); var arrivalEvent1 = new ArrivalEvent { Port = new Port { Name = "Roma" }, Version = 1 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent1); var departureEvent = new DepartureEvent { Port = new Port { Name = "Roma" }, Version = 2 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent); var departureEvent1 = new DepartureEvent { Port = new Port { Name = "Barcelona" }, Version = 4 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent1); var arrivalEvent2 = new ArrivalEvent { Port = new Port { Name = "Mallorca" }, Version = 5 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent2); var departureEvent2 = new DepartureEvent { Port = new Port { Name = "Mallorca" }, Version = 6 }; aggreate.ApplyEvent(departureEvent2); Assert.AreEqual("In Navigation", aggreate.State); }
private void SetWaypoint(Waypoint waypoint) { _nextWaypoint = waypoint; if (null == _nextWaypoint) { RouteCompleteEvent?.Invoke(this, EventArgs.Empty); } else { // TODO: we actually only wnat to send this // when our cooldown (if we have one) is up DepartureEvent?.Invoke(this, EventArgs.Empty); } }
public void DepartureShipEventSuccess() { var p = new Port() { Name = "port name", IntlCode = "intl code of port" }; var s = new Ship("id", "ship name", "ship reg code", p); var @event = new DepartureEvent(DateTime.Now, "id", new TestEntityRef <Ship>("id", s), p); @event.Process(); Assert.Equal("ship name", s.Name); Assert.Equal("ship reg code", s.RegistrationCode); Assert.NotNull(s.Location); Assert.Equal(Port.AT_SEA.IntlCode, s.Location.IntlCode); }
public void AddEventsToSnapShotShip() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 3 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); var arrivalEvent1 = new ArrivalEvent { Port = new Port { Name = "Roma" }, Version = 1 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent1); var departureEvent = new DepartureEvent { Port = new Port { Name = "Roma" }, Version = 2 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent); var departureEvent1 = new DepartureEvent { Port = new Port { Name = "Barcelona" }, Version = 4 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent1); var arrivalEvent2 = new ArrivalEvent { Port = new Port { Name = "Mallorca" }, Version = 5 }; _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent2).CreateSnapShot(); var departureEvent2 = new DepartureEvent { Port = new Port { Name = "Mallorca" }, Version = 6 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, departureEvent2); Assert.AreEqual(Port.AtSea, aggreate.Root.Port); }
public void ScheduleDepartureEvent(double timeIn, Job jobIn) { DepartureEvent departureEvent = new DepartureEvent(timeIn, this.manager, jobIn); this.ScheduleEvent(departureEvent); }
public void HandleDeparture(DepartureEvent ev) { // Here we set the Port to the Port Set by the DepartureEvent Location = ev.Port; }
public void HandleDeparture(DepartureEvent departureEvent) { Port = Port.AT_SEA; }
public void Departure(DepartureEvent @event) { Location = Port.AT_SEA; }