Пример #1
0
        public void TestSpyMarshal()
        {
            Piece att = new Spy(Ownership.FirstPlayer);
            ICell def = new Marshal(Ownership.SecondPlayer);

            Assert.True(att == ConflictHandler.Handle(att, def));
        }
Пример #2
0
        // TODO: Change signature?
        // TODO: TEST
        public Boolean ApplyValidMove(Position start, Position end)
        {
            // Hold both pieces
            // try:
            //     ask conflict handler for result
            // try:
            //     put the result at end position
            //    put an empty at start position

            Piece attacker;
            ICell defender;

            try
            {
                attacker = (Piece)CellAtPos(start);
                defender = CellAtPos(end);
            }
            catch
            {
                return(false);
            }

            if (attacker == null || defender == null)
            {
                return(false);
            }

            ICell winner = ConflictHandler.Handle(attacker, defender);

            State[end.to_board_index(DefaultBoardSize)]   = winner;
            State[start.to_board_index(DefaultBoardSize)] = new EmptyCell();
            return(true);
        }
Пример #3
0
        public void TestMinerEmpty()
        {
            Piece att = new Miner(Ownership.FirstPlayer);
            ICell def = new EmptyCell();

            Assert.True(att == ConflictHandler.Handle(att, def));
        }
Пример #4
0
        public void TestMinerFlag()
        {
            Piece att = new Miner(Ownership.FirstPlayer);
            ICell def = new Flag(Ownership.SecondPlayer);

            Assert.True(att == ConflictHandler.Handle(att, def));
        }
Пример #5
0
        public void TestMinerLieutenant()
        {
            Piece att = new Miner(Ownership.FirstPlayer);
            Piece def = new Lieutenant(Ownership.SecondPlayer);

            Assert.True(def == ConflictHandler.Handle(att, def));
        }
Пример #6
0
        public void TestColonelColonel()
        {
            Piece att = new Colonel(Ownership.FirstPlayer);
            Piece def = new Colonel(Ownership.SecondPlayer);

            Assert.True(ConflictHandler.Handle(att, def) is EmptyCell);
        }
Пример #7
0
        public void TestMajorGeneral()
        {
            Piece att = new Major(Ownership.SecondPlayer);
            ICell def = new General(Ownership.FirstPlayer);

            Assert.True(def == ConflictHandler.Handle(att, def));
        }
Пример #8
0
        public void TestMinerBomb()
        {
            Piece att = new Miner(Ownership.FirstPlayer);
            Piece def = new Bomb(Ownership.SecondPlayer);
            ICell ans = ConflictHandler.Handle(att, def);

            Assert.True(att == ans);
        }
Пример #9
0
        public void TestFailOnSameSideAttackColonalFlag__ThrowsPieceConflictHandlerException()
        {
            Piece att = new Colonel(Ownership.SecondPlayer);
            ICell def = new Flag(Ownership.SecondPlayer);

            TestDelegate code = () => ConflictHandler.Handle(att, def);

            Assert.Throws(typeof(PieceConflictHandlerException), code);
        }
Пример #10
0
        public void TestFailOnSameSideAttackSpySergeant__ThrowsPieceConflictHandlerException()
        {
            Piece att = new Spy(Ownership.FirstPlayer);
            ICell def = new Sergeant(Ownership.FirstPlayer);

            TestDelegate code = () => ConflictHandler.Handle(att, def);

            Assert.Throws(typeof(PieceConflictHandlerException), code);
        }
Пример #11
0
        public void TestFailOnAttackWaterMiner_ThrowsPieceConflictHandlerException()
        {
            Piece att = new Miner(Ownership.SecondPlayer);
            ICell def = new WaterCell();

            TestDelegate code = () => ConflictHandler.Handle(att, def);

            Assert.Throws(typeof(PieceConflictHandlerException), code);
        }
Пример #12
0
        public void TestFailOnAttackerBomb_ThrowsPieceConflictHandlerException()
        {
            Piece att = new Bomb(Ownership.FirstPlayer);
            ICell def = new Scout(Ownership.SecondPlayer);

            TestDelegate code = () => ConflictHandler.Handle(att, def);

            Assert.Throws(typeof(PieceConflictHandlerException), code);
        }
        public void Setup()
        {
            // Create fakes
            _FakeFlightHandler   = Substitute.For <IFlightHandler>();
            _FakeFlightValidator = Substitute.For <IFlightValidator>();

            _uut = Substitute.For <ConflictHandler>(300, 500);

            EmptyListFlights = new List <Flight>();

            ReturnedText = $"Conflicting flights and time of occurrence\r\nATY (15500, 15500, 16000) conflicts with PRQ (15600, 15450, 15900), Time of occurrence: {DateTime.Now}\r\n\r\n";

            testFlightsWithConflicts = new List <Flight>()
            {
                new Flight()
                {
                    tag      = "ATR423",
                    position = new Coords(10005, 8000, 14000),
                },
                new Flight()
                {
                    tag      = "DTY420",
                    position = new Coords(14005, 15000, 15500),
                },
                new Flight()
                {
                    tag      = "PRY696",
                    position = new Coords(10105, 7900, 13600),
                },
            };

            testFlightsNoConflicts = new List <Flight>()
            {
                new Flight()
                {
                    tag      = "ATR423",
                    position = new Coords(75005, 15600, 14056),
                },
                new Flight()
                {
                    tag      = "DTY420",
                    position = new Coords(50605, 20654, 18860),
                },
                new Flight()
                {
                    tag      = "PRY696",
                    position = new Coords(11005, 7900, 13600),
                },
            };

            _flight1 = new Flight
            {
                tag       = "ATY",
                position  = new Coords(15500, 15500, 16000),
                timestamp = DateTime.Now,
            };

            _flight2 = new Flight
            {
                tag       = "PRQ",
                position  = new Coords(15600, 15450, 15900),
                timestamp = DateTime.Now,
            };

            _conflict = new Conflict(_flight1, _flight2);
        }