Beispiel #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));
        }
Beispiel #2
0
        public void UnbanRoom(Room room)
        {
            this.storage.UnbanRoom(room);

            //REDO
            var computers = this.storage.GetComputers().Select(s => "computer-" + s.IpAddress);

            this.cachePrvoider.Invalidate(computers.ToArray());
            this.cachePrvoider.Invalidate("computers", "room-" + room.Name, "rooms");
        }
Beispiel #3
0
        public void CreateRoom()
        {
            var room = new Room
            {
                Id = 1,
                Name = "tester",
                Allowed = true
            };
            BanStorage.CreateRoom(room);

            Assert.AreEqual(2, BanStorage.GetRooms().Count());
        }
Beispiel #4
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));
        }
Beispiel #5
0
        public void CreateRoomTest()
        {
            Room room = new Room { Name = "Some room", Id = "Some room".GetHashCode() };

            BanStorage.CreateRoom(room);

            Assert.True(BanStorage.GetRooms().Contains(room));
        }
Beispiel #6
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));
        }
Beispiel #7
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));
        }
Beispiel #8
0
        public void AttachComputerToRoom(Computer computer, Room room)
        {
            this.storage.AttachComputerToRoom(computer, room);

            this.cachePrvoider.Invalidate("computers", "rooms", "computer-" + computer.IpAddress);
        }
Beispiel #9
0
 public IEnumerable<Computer> ComputersAttachedToRoom(Room room)
 {
     return this.storage.ComputersAttachedToRoom(room);
 }
Beispiel #10
0
        public void DeleteRoom(Room room)
        {
            this.storage.DeleteRoom(room);

            this.cachePrvoider.Invalidate("rooms", "room-" + room.Name);
        }
Beispiel #11
0
 public void UnbanRoomTest()
 {
     var room = new Room { Name = "Room", Allowed = false };
     this.BanStorage.CreateRoom(room);
     Assert.False(this.BanStorage.GetRoom("Room").Allowed);
     this.BanStorage.UnbanRoom(room);
     Assert.True(this.BanStorage.GetRoom("Room").Allowed);          
 }
Beispiel #12
0
        public void Setup()
        {
            this.computer = new Computer { IpAddress = "999.999.999.999", Banned = false };

            this.room = new Room { Name = "999", Allowed = true };
        }
Beispiel #13
0
 partial void DeleteRoom(Room instance);
Beispiel #14
0
 partial void UpdateRoom(Room instance);
Beispiel #15
0
 partial void InsertRoom(Room instance);