コード例 #1
0
ファイル: DeviceTest.cs プロジェクト: rwojcik/imsServer
        public void CreateContDeviceHistory()
        {
            var devicesGroup = new GroupModel
            {
                Id = 1,
                Description = "TestDescription",
                Devices = new List<DeviceModel>(),
                Name = "TestGroup",
            };

            devicesGroup.AuditEntity("TestUser");

            var model = new ContinousSettingDeviceModel
            {
                Id = 1,
                ContinousSetting = 20.5d,
                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 BinaryDeviceHistoryModel);

            Assert.IsTrue(historyEntity is ContinousDeviceHistoryModel);

            var contHistoryEntity = (ContinousDeviceHistoryModel) historyEntity;

            Assert.AreEqual(model.ContinousSetting, contHistoryEntity.ContinousSetting, 1d);
        }
コード例 #2
0
ファイル: DeviceTest.cs プロジェクト: rwojcik/imsServer
        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);
        }