Esempio n. 1
0
        public void CreateBinaryDeviceHistory()
        {
            var devicesGroup = new GroupModel
            {
                Id = 1,
                Description = "TestDescription",
                Devices = new List<DeviceModel>(),
                Name = "TestGroup",
            };

            devicesGroup.AuditEntity("TestUser");

            var model = new BinarySettingDeviceModel
            {
                Id = 1,
                BinarySetting = false,
                Description = "TestDescription",
                DeviceHistory = new List<DeviceHistoryModel>(),
                Name = "TestDevice",
                DeviceType = DeviceType.Thermometer,
                Group = devicesGroup,
                GroupId = devicesGroup.Id,
            };

            model.AuditEntity("TestUser");

            var historyEntity = model.CreateDeviceHistoryModel();

            Assert.IsNotNull(historyEntity);

            Assert.IsFalse(historyEntity is ContinousDeviceHistoryModel);

            Assert.IsTrue(historyEntity is BinaryDeviceHistoryModel);

            var contHistoryEntity = (BinaryDeviceHistoryModel)historyEntity;

            Assert.AreEqual(model.BinarySetting, contHistoryEntity.BinarySetting);
        }
Esempio n. 2
0
        public void CreateDeviceHistoryModelNoHistory()
        {
            var devicesGroup = new GroupModel
            {
                Id = 1,
                Description = "TestDescription",
                Devices = new List<DeviceModel>(),
                Name = "TestGroup",
            };

            devicesGroup.AuditEntity("TestUser");

            var model = new BinarySettingDeviceModel
            {
                Id = 1,
                BinarySetting = false,
                Description = "TestDescription",
                DeviceHistory = null,
                Name = "TestDevice",
                DeviceType = DeviceType.Thermometer,
                Group = devicesGroup,
                GroupId = devicesGroup.Id,
            };

            model.AuditEntity("TestUser");

            var viewModel = model.CreateDeviceViewModel();

            Assert.IsNull(viewModel.History);
        }