Ejemplo n.º 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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
 private void detach_Computers(Computer entity)
 {
     this.SendPropertyChanging();
     entity.Room = null;
 }
Ejemplo n.º 7
0
 partial void UpdateComputer(Computer instance);
Ejemplo n.º 8
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"));
        }
Ejemplo n.º 9
0
        public void UnbanComputer(Computer computer)
        {
            this.storage.UnbanComputer(computer);

            this.cachePrvoider.Invalidate("computers", "computer-" + computer.IpAddress);
        }
Ejemplo n.º 10
0
 public void DetachComputer(Computer computer)
 {
     this.cachePrvoider.Invalidate("computers", "rooms", "computer-" + computer.IpAddress); 
     
     this.storage.DetachComputer(computer);
 }
Ejemplo n.º 11
0
        public void AttachComputerToRoom(Computer computer, Room room)
        {
            this.storage.AttachComputerToRoom(computer, room);

            this.cachePrvoider.Invalidate("computers", "rooms", "computer-" + computer.IpAddress);
        }
Ejemplo n.º 12
0
        public void CreateComputer(Computer computer)
        {
            this.storage.CreateComputer(computer);

            this.cachePrvoider.Invalidate("computer-" + computer.IpAddress, "computers");
        }
Ejemplo n.º 13
0
 public RoomAttachment GetAttachment(Computer computer)
 {
     return this.storage.GetAttachment(computer);
 }
Ejemplo n.º 14
0
        public void Setup()
        {
            this.computer = new Computer { IpAddress = "999.999.999.999", Banned = false };

            this.room = new Room { Name = "999", Allowed = true };
        }
Ejemplo n.º 15
0
 partial void DeleteComputer(Computer instance);
Ejemplo n.º 16
0
        public void DeleteComputerTest()
        {
            //Create computer with fake ip-address;
            Computer computer = new Computer { Banned = false, IpAddress = "999.999.999.989" };

            BanStorage.CreateComputer(computer);

            BanStorage.DeleteComputer(computer);

            Assert.False(BanStorage.GetComputers().Contains(computer));
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
0
 public Room GetRoom(Computer computer)
 {
     return this.storage.GetRoom(computer);
 }
Ejemplo n.º 19
0
 private void attach_Computers(Computer entity)
 {
     this.SendPropertyChanging();
     entity.Room = this;
 }
Ejemplo n.º 20
0
 partial void InsertComputer(Computer instance);