예제 #1
0
        public void DetachComputerTest()
        {
            //Create computer with fake ip-address;
            Computer computer = new Computer {
                Banned = false, IpAddress = "999.999.999.999"
            };

            Room room = new Room {
                Name = "Some room", Id = "Some room".GetHashCode()
            };



            //At the moment of developing this test attach method ( public void Attach(object entity) ) wasn't implemented;
            try
            {
                BanStorage.AttachComputerToRoom(computer, room);
            }
            catch (NotImplementedException)
            {
            }

            //public void Attach(object entity, bool asModified) wasn't implemented;
            try
            {
                BanStorage.DetachComputer(computer);
            }
            catch (NotImplementedException)
            {
            }

            Assert.True(computer.Room == null);

            Assert.False(room.Computers.Contains(computer));
        }
예제 #2
0
        public void BanRoomTest()
        {
            //Create computers with fake ip-address;
            Computer computer1 = new Computer {
                Banned = false, IpAddress = "999.999.999.997"
            };
            Computer computer2 = new Computer {
                Banned = true, IpAddress = "888.888.888.888"
            };

            Room room = new Room {
                Name = "Some room", Id = "Some room".GetHashCode()
            };


            //At the moment of developing this test attach method wasn't implemented;
            try
            {
                BanStorage.AttachComputerToRoom(computer1, room);
                BanStorage.AttachComputerToRoom(computer2, room);
            }
            catch (NotImplementedException)
            {
            }

            BanStorage.CreateRoom(room);

            BanStorage.BanRoom(room);

            Assert.False(BanStorage.GetRoom("Some room").Allowed);

            Assert.True(BanStorage.GetRoom("Some room").Computers.All(c => c.Banned));
        }
예제 #3
0
        public void UnbanRoomTest()
        {
            Room room = new Room {
                Name = "Some Room", Id = "Some Room".GetHashCode(), Allowed = false
            };

            BanStorage.CreateRoom(room);

            //Create computers with fake ip-address;
            Computer computer1 = new Computer {
                Banned = true, IpAddress = "999.999.999.998"
            };


            //At the moment of developing this test attach method wasn't implemented;
            try
            {
                BanStorage.AttachComputerToRoom(computer1, room);
            }
            catch (NotImplementedException)
            {
            }

            BanStorage.UnbanRoom(room);

            Assert.True(BanStorage.GetRoom(room.Name).Allowed);

            Assert.True(room.Allowed);

            //Check if computers in this room are banned;
            //The testing method failed at this place;
            // Assert.True(BanStorage.GetRoom(room.Name).Computers.All(c => c.Banned == false));
        }
예제 #4
0
        public void UnbanComputerTest()
        {
            //Create computers with fake ip-address;
            Computer computer1 = new Computer {
                Banned = false, IpAddress = "999.999.999.997"
            };
            Computer computer2 = new Computer {
                Banned = true, IpAddress = "888.888.888.888"
            };


            BanStorage.CreateComputer(computer1);
            BanStorage.CreateComputer(computer2);

            BanStorage.BanComputer(computer1);

            BanStorage.UnbanComputer(computer1);

            Assert.False(computer1.Banned);

            //Check if computer was marked as unbaned in BanStorage;
            Assert.False(BanStorage.GetComputers().First(c => c.IpAddress == computer1.IpAddress).Banned);

            BanStorage.UnbanComputer(computer2);

            Assert.False(computer2.Banned);
        }
예제 #5
0
        public void AttachComputerToRoom()
        {
            var computer = BanStorage.GetComputers().First();
            var room     = BanStorage.GetRooms().First();

            BanStorage.AttachComputerToRoom(computer, room);

            Assert.AreEqual(room.Id, computer.Room.Id);
        }
예제 #6
0
        public void CreateRoomTest()
        {
            Room room = new Room {
                Name = "Some room", Id = "Some room".GetHashCode()
            };

            BanStorage.CreateRoom(room);

            Assert.True(BanStorage.GetRooms().Contains(room));
        }
예제 #7
0
        public void AttachComputerToRoom()
        {
            this.BanStorage.CreateComputer(this.computer);
            this.BanStorage.CreateRoom(this.room);


            BanStorage.AttachComputerToRoom(this.computer, this.room);

            Assert.AreEqual(this.BanStorage.ComputersAttachedToRoom(this.room).Contains(this.computer), true);
        }
예제 #8
0
        public void AttachComputerToRoom()
        {
            var computer = this.BanStorage.GetComputers().First();
            var room     = this.BanStorage.GetRooms().First();

            BanStorage.AttachComputerToRoom(computer, room);
            // computer.RoomRef = room.Id;

            //REDO
            //Assert.AreEqual(room.Id, computer.Room.Id);
        }
예제 #9
0
        public void CreateComputerTest()
        {
            //Create computer with fake ip-address;
            Computer computer = new Computer {
                Banned = false, IpAddress = "999.999.999.999"
            };

            BanStorage.CreateComputer(computer);

            Assert.True(BanStorage.GetComputers().Contains(computer));
        }
예제 #10
0
        public void GetComputerTest()
        {
            //Create computer with fake ip-address;
            Computer computer = new Computer {
                Banned = true, IpAddress = "999.949.999.979"
            };

            BanStorage.CreateComputer(computer);

            Assert.True(BanStorage.GetComputer("999.949.999.979").Banned);
        }
예제 #11
0
        public void DeleteRoomTest()
        {
            Room room = new Room {
                Name = "Some room 1", Id = "Some room 1".GetHashCode()
            };

            BanStorage.CreateRoom(room);

            BanStorage.DeleteRoom(room);

            Assert.False(BanStorage.GetRooms().Contains(room));
        }
예제 #12
0
        public void CreateRoom()
        {
            var room = new Room
            {
                Id      = 1,
                Name    = "tester",
                Allowed = true
            };

            BanStorage.CreateRoom(room);

            Assert.AreEqual(2, BanStorage.GetRooms().Count());
        }
예제 #13
0
        public void BanComputerTest()
        {
            //Create computer with fake ip-address;
            Computer computer = new Computer {
                Banned = false, IpAddress = "999.999.999.999"
            };

            BanStorage.CreateComputer(computer);

            BanStorage.BanComputer(computer);

            Assert.True(computer.Banned);

            //Check if banned computer is added to BanStorage;
            Assert.True(BanStorage.GetComputers().SingleOrDefault(c => c.IpAddress == computer.IpAddress).Banned);
        }
예제 #14
0
        public void ifBannedTest()
        {
            //Create computers with fake ip-address;
            Computer computer1 = new Computer {
                Banned = true, IpAddress = "999.949.999.979"
            };
            Computer computer2 = new Computer {
                Banned = false, IpAddress = "969.949.999.979"
            };

            BanStorage.CreateComputer(computer1);

            BanStorage.CreateComputer(computer2);

            Assert.True(BanStorage.ifBanned("999.949.999.979"));
            Assert.False(BanStorage.ifBanned("969.949.999.979"));
        }
예제 #15
0
        public void CreateComputer()
        {
            BanStorage.CreateComputer(new Computer());

            Assert.AreEqual(2, BanStorage.GetComputers().Count());
        }