Exemplo n.º 1
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public void DockTheShip(int beer)
        {
            var ev = new ArrivalEvent(DateTime.Now, ship, port);

            eventProcessor.Process(ev);
            Assert.Equal(port, ship.Port);
        }
Exemplo n.º 5
0
        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);
            }
        }
Exemplo n.º 6
0
 public void HandleArrival(ArrivalEvent ev)
 {
     Port = ev.Port;
     foreach (Cargo c in cargo)
     {
         c.HandleArrival(ev);
     }
 }
Exemplo n.º 7
0
 public void HandleArrival(ArrivalEvent ev)
 {
     ev.priorCargoInCanada[this] = _hasBeenInCanada;
     if ("CA" == ev.Port.Country)
     {
         _hasBeenInCanada = true;
     }
     declaredValue = Registry.PricingGateway.GetPrice(this);
 }
Exemplo n.º 8
0
        public void CuandoSeAñadeSeGuardaCorrectamente()
        {
            var arrivalEvent = new ArrivalEvent {
                Port = new Port {
                    Name = "Barcelona"
                }
            };

            _eventsRepositorySql.AddEvent(1, arrivalEvent);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 16
0
 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;
 }
Exemplo n.º 17
0
    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");
        }
    }
Exemplo n.º 18
0
        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");
        }
Exemplo n.º 19
0
        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);
        }
Exemplo n.º 20
0
 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;
 }
Exemplo n.º 22
0
        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);
        }
Exemplo n.º 23
0
        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);
        }
Exemplo n.º 24
0
        public void ScheduleArrivalEvent(double timeIn, JobType jobTypeIn)
        {
            ArrivalEvent arrivalEvent = new ArrivalEvent(timeIn, this.manager, jobTypeIn);

            this.ScheduleEvent(arrivalEvent);
        }
Exemplo n.º 25
0
 public void HandleArrival(ArrivalEvent ev)
 {
     ev.Ship.Port = this;
     Registry.CustomsNotificationGateway.Notify(ev.Occurred, ev.Ship, ev.Port);
 }
Exemplo n.º 26
0
 public void HandleArrival(ArrivalEvent ev)
 {
     // Here we set the Port to the Port Set by the ArrivalEvent
     Location = ev.Port;
 }
Exemplo n.º 27
0
 void HandleReachDestination()
 {
     OnArrive();
     OnArrive = null;
     agent.ResetPath();
 }
Exemplo n.º 28
0
 public void ReverserArrival(ArrivalEvent ev)
 {
     _hasBeenInCanada = (bool)ev.priorCargoInCanada[this];
 }