示例#1
0
        public void EnsureCanRemoveDevice()
        {
            //Arrange
            Device first_device = new Device {
                DeviceID = 1, Name = "terminator"
            };
            Device second_device = new Device {
                DeviceID = 29, Name = "Johnny5"
            };

            //Act
            Repo.AddDevice(first_device);
            Repo.AddDevice(second_device);
            Repo.RemoveDevice(1);

            int expected_count = 1;
            int actual_count   = Repo.GetAllDevices().Count();
            int expected_id    = 29;
            int actual_id      = Repo.GetDeviceByID(29).DeviceID;


            //Assert
            Assert.AreEqual(expected_count, actual_count);
            Assert.AreEqual(expected_id, actual_id);
        }
示例#2
0
        public void EnsureCanAddNewDevice()
        {
            //Arrange
            Device first_device = new Device {
                DeviceID = 1, Name = "terminator"
            };
            Device second_device = new Device {
                DeviceID = 2, Name = "Johnny5"
            };

            //Act
            Repo.AddDevice(first_device);
            Repo.AddDevice(second_device);
            int expected_count = 2;
            int actual_count   = Repo.Context.Devices.Count();

            //Assert
            Assert.AreEqual(expected_count, actual_count);
        }
示例#3
0
        public void EnsureCanGetDeviceByID()
        {
            //Arrange
            Device first_device = new Device {
                DeviceID = 1, Name = "terminator"
            };
            Device second_device = new Device {
                DeviceID = 2, Name = "Johnny5"
            };

            //Act
            Repo.AddDevice(first_device);
            Repo.AddDevice(second_device);
            int    expected_id  = 1;
            Device found_device = Repo.GetDeviceByID(1);
            int    actual_id    = found_device.DeviceID;

            //Assert
            Assert.IsNotNull(found_device);
            Assert.AreEqual(expected_id, actual_id);
        }