Beispiel #1
0
        public void TestFalse()
        {
            var solution = new KeysAndRooms();
            IList <IList <int> > input = new List <IList <int> >();

            input.Add(new List <int>()
            {
                1, 3
            });
            input.Add(new List <int>()
            {
                3, 0, 1
            });
            input.Add(new List <int>()
            {
                2
            });
            input.Add(new List <int>()
            {
                0
            });

            var visited = solution.CanVisitAllRooms(input);

            Assert.AreEqual(false, visited);
        }
        public void CanVisitAllRooms(List <List <int> > rooms, bool expected)
        {
            var sut    = new KeysAndRooms();
            var actual = sut.CanVisitAllRooms(rooms);

            Assert.AreEqual(expected, actual);
        }
Beispiel #3
0
        public void Case_0()
        {
            var rooms = new List <IList <int> >()
            {
                new List <int>()
                {
                    1
                }, new List <int>()
                {
                    2
                }, new List <int>()
                {
                    3
                }, new List <int>()
            };

            var roomVisitor = new KeysAndRooms();

            Assert.True(roomVisitor.CanVisitAllRooms(rooms));
        }
Beispiel #4
0
        public void Case_1()
        {
            var rooms = new List <IList <int> >()
            {
                new List <int>()
                {
                    1, 3
                }, new List <int>()
                {
                    3, 0, 1
                }, new List <int>()
                {
                    2
                }, new List <int>()
                {
                    0
                }
            };

            var roomVisitor = new KeysAndRooms();

            Assert.False(roomVisitor.CanVisitAllRooms(rooms));
        }
Beispiel #5
0
        public void TestTrue()
        {
            var solution = new KeysAndRooms();
            IList <IList <int> > input = new List <IList <int> >();

            input.Add(new List <int>()
            {
                1
            });
            input.Add(new List <int>()
            {
                2
            });
            input.Add(new List <int>()
            {
                3
            });
            input.Add(new List <int>());

            var visited = solution.CanVisitAllRooms(input);

            Assert.AreEqual(true, visited);
        }