예제 #1
0
        public void GetAllPropertiesKeys()
        {
            var device           = new Device(_device1.Id, _device1.Name, true, _device1.Type, DeviceStatus.Online);
            var device2          = 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;
            device2.Properties = deviceProperties;

            // Arrange
            var mockRepository = new Mock <IRepository <Device> >();

            mockRepository.Setup(repo => repo.GetAll())
            .Returns(new List <Device> {
                device, device2
            });

            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.GetAllPropertiesKeys();

            // Assert
            var viewResult = Assert.IsType <JsonResult>(result);

            Assert.Equal(new List <string> {
                "key1", "key2"
            }, viewResult.Value);
        }