public void GetPropertiesById_Found() { var device = new Device(_device1.Id, _device1.Name, true, _device1.Type, DeviceStatus.Online); var deviceProperties = new List <DeviceProperties> { new DeviceProperties("key1", "value1"), new DeviceProperties("key2", "value2") }; device.Properties = deviceProperties; // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(device.Id)) .Returns(device); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetPropertiesById(device.Id); // Assert var viewResult = Assert.IsType <JsonResult>(result); Assert.Equal(deviceProperties, viewResult.Value); }
public void GetPropertiesById_DeviceNotFound() { // Arrange var mockRepository = new Mock <IRepository <Device> >(); mockRepository.Setup(repo => repo.Find(_device1.Id)) .Returns((Device)null); var mockLogger = new Mock <IManagerLogger>(); var mockConfiguration = new Mock <IManagerConfiguration>(); var controller = new DevicesController(mockRepository.Object, mockLogger.Object, mockConfiguration.Object, null, null, _externalProcesses); // Act var result = controller.GetPropertiesById(_device1.Id); // Assert Assert.IsType <NotFoundObjectResult>(result); }