Exemplo n.º 1
0
        public void WhenInialised_CheckTheNumberOfDoors()
        {
            var house = new FlippingDoors();
            var size  = house.Doors.Count();

            Assert.AreEqual(size, numDoors);
        }
Exemplo n.º 2
0
        public void BeforeAnyRun_CheckStateOfDoors_ShouldBeAllClosed()
        {
            var house = new FlippingDoors();

            var allDoorsClosed = house.Doors.All(x => x.State == DoorState.Closed);

            Assert.IsTrue(allDoorsClosed);
        }
Exemplo n.º 3
0
        public void CheckStatesAfte4thRun(int num)
        {
            var house = new FlippingDoors();
            var door  = house.Doors;

            Logic.DoSomeFlipping(num, ref door);

            Assert.IsTrue(door[83].State == DoorState.Closed);
            Assert.IsTrue(door[84].State == DoorState.Opened);
            Assert.IsTrue(door[85].State == DoorState.Closed);
        }
Exemplo n.º 4
0
        public void AfterFirstRun_CheckStateOfEverySecondDoor_ShouldBeClosed(int num)
        {
            var house = new FlippingDoors();
            var door  = house.Doors;

            Logic.DoSomeFlipping(num, ref door);

            var allDoorsOpened = door.All(x => x.State == DoorState.Opened);

            Assert.IsTrue(allDoorsOpened);
        }
Exemplo n.º 5
0
        public void CheckStatesAfteSecondRun(int num)
        {
            var house = new FlippingDoors();
            var door  = house.Doors;

            Logic.DoSomeFlipping(num, ref door);

            var AllSecondDorrsClosed = door.Where((x, i) => (i + 1) % num == 0).
                                       All((x => x.State == DoorState.Closed));

            Assert.IsTrue(AllSecondDorrsClosed);
        }
Exemplo n.º 6
0
        public void CheckStatesAfterNthRun(int num)
        {
            var house = new FlippingDoors();
            var door  = house.Doors;

            Logic.DoSomeFlipping(num, ref door);

            var allNthDoorsOpened = door.Where((x, i) => i % num == 0).
                                    All((x => x.State == DoorState.Opened));

            Assert.IsTrue(allNthDoorsOpened);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            var house = new FlippingDoors();
            var door  = house.Doors;

            Logic.DoSomeFlipping(0, ref door);
            Console.Write("0  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(1, ref door);
            Console.Write("1  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(2, ref door);
            Console.Write("2  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(3, ref door);
            Console.Write("3  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(4, ref door);
            Console.Write("4  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(5, ref door);
            Console.Write("5  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(6, ref door);
            Console.Write("6  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(7, ref door);
            Console.Write("7  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(8, ref door);
            Console.Write("8  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(9, ref door);
            Console.Write("9  : ");
            Output(door);

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(10, ref door);
            Console.Write("10 : ");
            Output(door);

            Console.WriteLine(".");
            Console.WriteLine(".");
            Console.WriteLine(".");
            Console.WriteLine(".");
            Console.WriteLine(".");

            house = new FlippingDoors();
            door  = house.Doors;
            Logic.DoSomeFlipping(100, ref door);
            Console.Write("100 : ");
            Output(door);
            Console.ReadLine();
        }