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); }
public void CreateDeviceHistoryModelWithHistory() { 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 historyModel = model.CreateDeviceHistoryModel(); model.DeviceHistory.Add(historyModel); var viewModel = model.CreateDeviceViewModel(); Assert.IsNotNull(viewModel); Assert.IsTrue(viewModel.History.Any()); }