Exemplo n.º 1
0
        public void ListDevice_NoDevicesOnDB_NoDevicesFound()
        {
            IDeviceRepository fakeDeviceRepository = A.Fake<IDeviceRepository>();
            var listDevices = new ListDevices(fakeDeviceRepository);

            var response = listDevices.Execute();

            Assert.AreEqual("No Devices Found", response);
        }
Exemplo n.º 2
0
        public void ListDevices_TwoDevicesOnDB_BothDevicesShown()
        {
            const string someDeviceName = "light";
            const string otherDeviceName = "light2";
            const int someIntDeviceState = 100;

            var expectedResponse =
                someDeviceName + ", State: " +
                someIntDeviceState +
                Environment.NewLine +
                otherDeviceName + ", State: " +
                someIntDeviceState;

            IDeviceRepository fakeDeviceRepository = A.Fake<IDeviceRepository>();
            var deviceRepo = new ConcurrentDictionary<string, SettableDevice>();
            deviceRepo.TryAdd(someDeviceName, new SettableDevice(someDeviceName, someIntDeviceState));
            deviceRepo.TryAdd(otherDeviceName, new SettableDevice(otherDeviceName, someIntDeviceState));
            A.CallTo(() => fakeDeviceRepository.GetDevices()).Returns(deviceRepo);

            ListDevices listDevices = new ListDevices(fakeDeviceRepository);

            var response = listDevices.Execute();
            Assert.AreEqual(expectedResponse, response);
        }