Example #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));
        }
Example #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));
        }
Example #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));
        }
Example #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);
        }
Example #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);
        }
Example #6
0
 private void detach_Computers(Computer entity)
 {
     this.SendPropertyChanging();
     entity.Room = null;
 }
Example #7
0
 partial void UpdateComputer(Computer instance);
Example #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"));
        }
Example #9
0
        public void UnbanComputer(Computer computer)
        {
            this.storage.UnbanComputer(computer);

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

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

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

            this.room = new Room { Name = "999", Allowed = true };
        }
Example #15
0
 partial void DeleteComputer(Computer instance);
Example #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));
        }
Example #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);
        }
Example #18
0
 public Room GetRoom(Computer computer)
 {
     return this.storage.GetRoom(computer);
 }
Example #19
0
 private void attach_Computers(Computer entity)
 {
     this.SendPropertyChanging();
     entity.Room = this;
 }
Example #20
0
 partial void InsertComputer(Computer instance);