public void GivenCondensedWorkStateWithNoInstalledWhenCreateMetersThenNoMetersCreated()
        {
            var spatialRow = new ISOSpatialRow();
            const long value = 0xFFFFFFFF;
            var spatialValue = new SpatialValue
            {
                Dlv = new DLV
                {
                    A = "16F"
                },
                Value = value
            };
            spatialRow.SpatialValues = new List<SpatialValue> { spatialValue };
            _isoSpatialRows = new List<ISOSpatialRow> { spatialRow };
            var result = new CondensedSectionOverrideStateMeterCreator(367).CreateMeters(_isoSpatialRows);

            Assert.AreEqual(0, result.Count);
        }
        public void GivenDdi162WhenCreateMetersThenSectionsStartWith17()
        {
            var result = new CondensedSectionOverrideStateMeterCreator(368).CreateMeters(_isoSpatialRows);

            CheckConsolidatedWorkStateSectionIds(result, 17);
        }
        public void GivenCondensedWorkStateWithSomeStatesNotInstalledThenOnlyCreatesInstalledSections()
        {
            var spatialRow = new ISOSpatialRow();
            const long notInstalled = 3;
            long value = 0;
            for (int i = 15; i > 11; --i)
            {
                value |= (notInstalled << i * 2);
            }
            var spatialValue = new SpatialValue
            {
                Dlv = new DLV
                {
                    A = "16F"
                },
                Value = value
            };
            spatialRow.SpatialValues = new List<SpatialValue> { spatialValue };
            _isoSpatialRows = new List<ISOSpatialRow> { spatialRow };
            var result = new CondensedSectionOverrideStateMeterCreator(367).CreateMeters(_isoSpatialRows);

            Assert.AreEqual(12, result.Count);
        }
        public void GivenMetersWithStartAt382WhenGetMetersValueThenValuesCorrect()
        {
            SpatialRecord spatialRecord;
            var meters = CreateMeters(out spatialRecord, 241);
            var creator = new CondensedSectionOverrideStateMeterCreator(382);

            var result = creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x44444444, result);
        }
        public void GivenCondensedWorkStateDdiWhenCreateMetersThenRepresentationIsSectionStatus()
        {
            var result = new CondensedSectionOverrideStateMeterCreator(367).CreateMeters(_isoSpatialRows);

            result.ForEach(x => Assert.AreEqual(x.Representation.Code, RepresentationInstanceList.dtPrescriptionState.DomainId));
        }
        public void GivenCondensedWorkStateDdiWhenCreateMetersThenMetersSectionsAreSet()
        {
            var result = new CondensedSectionOverrideStateMeterCreator(367).CreateMeters(_isoSpatialRows);

            CheckConsolidatedWorkStateSectionIds(result, 1);
        }
        public void GivenMetersWithStartAt367AndUndefinedWhenGetMetersValueThenValuesCorrect()
        {
            var meters = new List<WorkingData>();
            for (int i = 1; i < 17; i++)
            {
                meters.Add(new ISOEnumeratedMeter { DeviceElementUseId = i });
            }

            var spatialRecord = new SpatialRecord();
            for (var i = 0; i < 16; i++)
            {
                if (i % 2 == 0)
                    spatialRecord.SetMeterValue(meters[i],
                        new EnumeratedValue
                        {
                            Value = DefinedTypeEnumerationInstanceList.dtiSunny.ToModelEnumMember()
                        });
                else
                    spatialRecord.SetMeterValue(meters[i],
                        new EnumeratedValue
                        {
                            Value = DefinedTypeEnumerationInstanceList.dtiPrescriptionOverridden.ToModelEnumMember()
                        });
            }

            var creator = new CondensedSectionOverrideStateMeterCreator(367);
            var result = creator.GetMetersValue(meters, spatialRecord);
            Assert.AreEqual(0x77777777, result);
        }
        public void GivenDdiAndSpatialValueWithNotInstalledStateWhenGetValueForMeterThenPrescriptionNotUsedIsReturned()
        {
            var spatialValue = new SpatialValue
            {
                Dlv = new DLV
                {
                    A = "16F"
                },
                Value = 3
            };

            var meter = new EnumeratedWorkingData
            {
                DeviceElementUseId = 1
            };

            var result = new CondensedSectionOverrideStateMeterCreator(367).GetValueForMeter(spatialValue, meter);

            Assert.AreEqual(DefinedTypeEnumerationInstanceList.dtiPrescriptionNotUsed.ToModelEnumMember().Value, result.Value.Value);
        }
        public void GivenCondensedWorkStateDdiWhenCreateMetersThenMeters()
        {
            var result = new CondensedSectionOverrideStateMeterCreator(367).CreateMeters(_isoSpatialRows);

            Assert.AreEqual(16, result.Count);
        }