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 ArrivalSetsShipsLocation() { ArrivalEvent ev = new ArrivalEvent(new DateTime(2005, 11, 1), sfo, kr); eProc.Process(ev); Assert.AreEqual(sfo, kr.Port); }
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 DockTheShip(int beer) { var ev = new ArrivalEvent(DateTime.Now, ship, port); eventProcessor.Process(ev); Assert.Equal(port, ship.Port); }
protected virtual void FixedUpdate() { if (!CanMove) { return; } float dt = Time.fixedDeltaTime; _transform.MoveTowards(_nextWaypoint.Transform.position, _speed * dt); if (Vector3.Distance(_transform.position, _nextWaypoint.Transform.position) < float.Epsilon) { if (_nextWaypoint.HasCooldown) { _cooldown.Start(_nextWaypoint.Cooldown); } _transform.position = _nextWaypoint.Transform.position; ArrivalEvent?.Invoke(this, EventArgs.Empty); SetWaypoint(_nextWaypoint.NextWaypoint); } }
public void HandleArrival(ArrivalEvent ev) { Port = ev.Port; foreach (Cargo c in cargo) { c.HandleArrival(ev); } }
public void HandleArrival(ArrivalEvent ev) { ev.priorCargoInCanada[this] = _hasBeenInCanada; if ("CA" == ev.Port.Country) { _hasBeenInCanada = true; } declaredValue = Registry.PricingGateway.GetPrice(this); }
public void CuandoSeAñadeSeGuardaCorrectamente() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" } }; _eventsRepositorySql.AddEvent(1, arrivalEvent); }
public void CreateNewShip() { var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" }, Version = 1 }; var aggreate = _aggregateFactory.GetAndApplyEvent(_ship.Id, arrivalEvent); Assert.AreEqual("Barcelona", aggreate.Root.Port.Name); }
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 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); }
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 CuandoSeGeneraElSnapshotSeGuardaCorrectamente() { var ship = new Ship { Id = 1, Port = Port.AtSea, Version = 1 }; var arrivalEvent = new ArrivalEvent {Port = new Port {Name = "Barcelona"}}; _eventsRepositorySql.AddEvent(1, arrivalEvent); _eventsRepositorySql.SaveSnapShot(ship, SnapShotType.ByVersion, new[]{arrivalEvent}, "In Navigation"); }
public void When() { bool isActive = true; _eventProcessor = new EventProcessor(isActive); _shipKingRoy = new Ship("King Roy"); _customsApi = A.Fake <ICustomsApi> (); _customsEventGateway = new CustomsEventGateway(true, _customsApi); _portOfSanFrancisco = new Port("San Francisco", Country.US, _customsEventGateway); ArrivalEvent ev = new ArrivalEvent(new DateTime(2005, 11, 1), _portOfSanFrancisco, _shipKingRoy); _eventProcessor.Process(ev); }
public QuestSegment(int segmentID, Trigger trigger, bool skippable, string objective, string descriptionOfQuest, ArrivalEvent arrivalEvent, List <int> crewmembersToAdd, List <int> crewmembersToRemove, bool isFinalSegment, List <int> mentionedPlaces, Sprite image, string caption) { this.segmentID = segmentID; this.trigger = trigger; this.skippable = skippable; this.objective = objective; this.descriptionOfQuest = descriptionOfQuest; this.arrivalEvent = arrivalEvent; this.crewmembersToAdd = crewmembersToAdd; this.crewmembersToRemove = crewmembersToRemove; this.isFinalSegment = isFinalSegment; this.mentionedPlaces = mentionedPlaces; this.image = image; this.caption = caption; }
public bool SetDestination(Vector3 targetPosition, ArrivalEvent cb = null) { OnArrive = cb; NavMeshPath path = new NavMeshPath(); if (agent.CalculatePath(targetPosition, path)) { Debug.Log("Path found"); agent.SetPath(path); return(true); } else { HandleReachDestination(); return(false); Debug.Log("Path not found"); } }
public void CuandoSeGeneraElSnapshotSeGuardaCorrectamente() { var ship = new Ship { Id = 1, Port = Port.AtSea, Version = 1 }; var arrivalEvent = new ArrivalEvent { Port = new Port { Name = "Barcelona" } }; _eventsRepositorySql.AddEvent(1, arrivalEvent); _eventsRepositorySql.SaveSnapShot(ship, SnapShotType.ByVersion, new[] { arrivalEvent }, "In Navigation"); }
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 CuandoSeAñadeSeGuardaCorrectamente() { var arrivalEvent = new ArrivalEvent {Port = new Port {Name = "Barcelona"}}; _eventsRepositorySql.AddEvent(1, arrivalEvent); }
public void Process(ArrivalEvent ev) { ev.Ship.Port = ev.Port; }
public void ScheduleArrivalEvent(double timeIn, JobType jobTypeIn) { ArrivalEvent arrivalEvent = new ArrivalEvent(timeIn, this.manager, jobTypeIn); this.ScheduleEvent(arrivalEvent); }
public void HandleArrival(ArrivalEvent ev) { ev.Ship.Port = this; Registry.CustomsNotificationGateway.Notify(ev.Occurred, ev.Ship, ev.Port); }
public void HandleArrival(ArrivalEvent ev) { // Here we set the Port to the Port Set by the ArrivalEvent Location = ev.Port; }
void HandleReachDestination() { OnArrive(); OnArrive = null; agent.ResetPath(); }
public void ReverserArrival(ArrivalEvent ev) { _hasBeenInCanada = (bool)ev.priorCargoInCanada[this]; }