Пример #1
0
 public void SetShipOwner(ShipOwner shipOwner)
 {
     if (shipOwner == null)
     {
         throw new ArgumentNullException("Ship Owner is null!");
     }
     SetShipOwner(shipOwner.Id);
 }
Пример #2
0
        public void ShouldAddToRepositoryAndReturnTrue()
        {
            var shipOwner = new ShipOwner();

            shipOwnerRepositoryMock.Setup(x => x.Find(shipOwnerId)).Returns(shipOwner);
            var entity = new Ship();

            var result = service.Add(entity, shipOwnerId);

            Assert.IsTrue(result);
            Assert.AreEqual(shipOwner, entity.ShipOwner);
            repositoryMock.Verify(x => x.Add(entity), Times.Once());
            shipOwnerRepositoryMock.Verify(x => x.Find(shipOwnerId), Times.Once());
        }
Пример #3
0
        public void ShouldNotSetClosestScheduleWhenItIsNotInFuture()
        {
            var shipOwner = new ShipOwner();

            shipOwnerRepositoryMock.Setup(x => x.Find(shipOwnerId)).Returns(shipOwner);
            var entity = new Ship
            {
                Schedules = new List <Schedule> {
                    new Schedule()
                }
            };

            var result = service.Add(entity, shipOwnerId);

            Assert.AreEqual(null, entity.ClosestSchedule);
        }
        public void ShouldReturnEntityById()
        {
            var entity = new ShipOwner {
                Id = 1, Name = "test"
            };
            var dbEntities = new List <ShipOwner> {
                entity
            };
            var dbSet = GetQueryableMockDbSet(dbEntities);

            contextMock.SetupGet(x => x.ShipOwners).Returns(dbSet);

            var result = repository.Find(entity.Id);

            Assert.AreEqual(entity, result);
        }
Пример #5
0
        public void ShouldSetClosestScheduleWhenItIsInFuture()
        {
            var shipOwner = new ShipOwner();

            shipOwnerRepositoryMock.Setup(x => x.Find(shipOwnerId)).Returns(shipOwner);
            var entity = new Ship
            {
                Schedules = new List <Schedule> {
                    new Schedule {
                        Arrival = DateTime.Now.AddDays(1)
                    }
                }
            };

            var result = service.Add(entity, shipOwnerId);

            Assert.AreEqual(entity.Schedules.ElementAt(0), entity.ClosestSchedule);
        }
Пример #6
0
 public BeginShipTile(float yBegin, float yEnd, float viewXShift, Quadrangle hitBound, int type, List <Quadrangle> collisionRectangles, bool traversable, TypeOfEnemyShip typeOfEnemyShip)
     : base(yBegin, yEnd, viewXShift, hitBound, type, collisionRectangles, traversable)
 {
     this.typeOfEnemyShip = typeOfEnemyShip;
     if (typeOfEnemyShip == TypeOfEnemyShip.PatrolBoat)
     {
         ShipOwner = new PatrolBoatManager(typeOfEnemyShip);
     }
     else if (typeOfEnemyShip == TypeOfEnemyShip.WarShip)
     {
         ShipOwner = new WarShipManager(typeOfEnemyShip);
     }
     else if (typeOfEnemyShip == TypeOfEnemyShip.Submarine)
     {
         ShipOwner = new SubmarineManager(typeOfEnemyShip);
     }
     else
     {
         throw new ArgumentException("Nie dozwolona wartosc dla parametru", "typeOfEnemyShip");
     }
     ShipOwner.AddShipTile(this);
 }
Пример #7
0
        public static void SeedDatabase(ApplicationContext context)
        {
            if (!context.Configurations.Any(x => x.ConfigurationType == ConfigurationType.RemoteServiceAddress))
            {
                context.Configurations.Add(new Configuration
                {
                    ConfigurationType = ConfigurationType.RemoteServiceAddress,
                    Value             = "http://localhost:4444/Port/ComplexMessage"
                });
            }
            if (context.ShipOwners.Any())
            {
                return;
            }

            var shipAlreadyInPort  = CreateShip("Alabama");
            var shipThatWillArrive = CreateShip("California");
            var shipWithoutArrival = CreateShip("Mississippi");
            var now = DateTime.Now;

            now = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0, DateTimeKind.Local);


            var scheduleInMinute = new Schedule
            {
                Arrival     = now.AddHours(-1),
                Departure   = now.AddMinutes(2),
                ArrivalSent = true,
            };

            var oldSchedule = new Schedule
            {
                Arrival       = now.AddDays(-1),
                Departure     = now.AddHours(-2),
                ArrivalSent   = true,
                DepartureSent = true
            };

            var schedule2 = new Schedule
            {
                Arrival       = now.AddMinutes(3),
                Departure     = now.AddMinutes(8),
                ArrivalSent   = false,
                DepartureSent = false
            };

            var futureSchedule = new Schedule
            {
                Arrival     = now.AddHours(10),
                Departure   = now.AddHours(15),
                ArrivalSent = false,
            };

            var schedule3 = new Schedule
            {
                Arrival     = now.AddHours(20),
                Departure   = now.AddMinutes(30),
                ArrivalSent = false,
            };

            var oldSchedules = new List <Schedule>();

            oldSchedules.AddRange(CreateSchedulesTwoWeeksBefore(now));
            oldSchedules.AddRange(CreateSchedulesWeekBefore(now));
            shipWithoutArrival.Schedules = oldSchedules;

            shipAlreadyInPort.Schedules = new List <Schedule> {
                scheduleInMinute, futureSchedule, schedule3
            };
            shipAlreadyInPort.ClosestSchedule = scheduleInMinute;

            shipThatWillArrive.Schedules = new List <Schedule> {
                schedule2
            };
            shipThatWillArrive.ClosestSchedule = schedule2;
            var shipOwner = new ShipOwner
            {
                Ships = new List <Ship> {
                    shipThatWillArrive, shipAlreadyInPort, shipWithoutArrival
                },
                Name = "United States Navy"
            };

            context.ShipOwners.Add(shipOwner);

            context.SaveChanges();
        }