コード例 #1
0
        public void Test_ValidateIsRightfulTypeVessels()
        {
            var factory = new VesselFactory();

            IList<IVessel> allVessels = factory.CreateAllVessels();

            if (allVessels[0].Positions.Count == 5)
            {
                Assert.AreEqual(4, allVessels[1].Positions.Count);
                Assert.AreEqual(4, allVessels[2].Positions.Count);
            }
            else if (allVessels[1].Positions.Count == 5)
            {
                Assert.AreEqual(4, allVessels[0].Positions.Count);
                Assert.AreEqual(4, allVessels[2].Positions.Count);
            }
            else if (allVessels[2].Positions.Count == 5)
            {
                Assert.AreEqual(4, allVessels[0].Positions.Count);
                Assert.AreEqual(4, allVessels[1].Positions.Count);
            }
            else
            {
                throw new InvalidProgramException("The start Vessels collection should be contain exactly 1 Battleship and 2 Destroyers");
            }
        }
コード例 #2
0
        public void Test_ValidateStartNumberOfVessels()
        {
            var factory = new VesselFactory();

            var allVessels = factory.CreateAllVessels();

            Assert.AreEqual(3, allVessels.Count);
        }
コード例 #3
0
        public void Test_ValidateIsVesselsPositionsNotOverlaps()
        {
            var factory = new VesselFactory();

            IList<IVessel> allVessels = factory.CreateAllVessels();

            var allUniqePositions = new HashSet<IPosition>();

            foreach (IVessel vessel in allVessels)
            {
                foreach (IPosition position in vessel.Positions)
                {
                    allUniqePositions.Add(position);
                }
            }

            Assert.AreEqual(13, allUniqePositions.Count);
        }