private IAttributeData Attribute(bool hasChangePoints, object attributeValue)
        {
            if (hasChangePoints)
            {
                var attribute = new AttributeData(null);
                attribute.AddChangepoints(ChangePoints(decimal.Parse(attributeValue.ToString())));

                return(attribute);
            }

            return(new AttributeData(attributeValue));
        }
        public void GetDecimalAttributeValueForPeriod(int period, object value, decimal assertion)
        {
            var attribute    = new AttributeData(null);
            var changePoints = new List <TemporalValueItem>
            {
                new TemporalValueItem(new DateTime(2018, period, 1), value, string.Empty),
                new TemporalValueItem(new DateTime(2018, 10, 1), "1", string.Empty)
            };

            attribute.AddChangepoints(changePoints);

            NewService().GetDecimalAttributeValueForPeriod(attribute, new DateTime(2018, period, 1)).Should().Be(assertion);
        }
Exemplo n.º 3
0
        public void SessionBuilder_MapTemporal_Count()
        {
            // ARRANGE
            var sessionBuilder = new SessionBuilder();

            var attributeData = new AttributeData(12345678);

            attributeData.AddChangepoints(TestChangePoints());

            // ACT
            var temporal = sessionBuilder.MapTemporalValue(attributeData.Changepoints);

            // ASSERT
            temporal.Count.Should().Be(2);
        }
Exemplo n.º 4
0
        public void SessionBuilder_MapTemporal_Correct()
        {
            // ARRANGE
            var sessionBuilder = new SessionBuilder();

            var attributeData = new AttributeData(12345678);

            attributeData.AddChangepoints(TestChangePoints());

            // ACT
            var temporal = sessionBuilder.MapTemporalValue(attributeData.Changepoints);

            // ASSERT
            temporal.Should().NotBeNull();
            temporal[0].ToString().Should().BeEquivalentTo("100.0@2017-08-01");
            temporal[1].ToString().Should().BeEquivalentTo("100.0@2017-09-01");
        }
        public void AddChangePoints()
        {
            var temporalValueItemOne   = new TemporalValueItem(new DateTime(2017, 1, 1), null, null);
            var temporalValueItemTwo   = new TemporalValueItem(new DateTime(2017, 1, 1), null, null);
            var temporalValueItemThree = new TemporalValueItem(new DateTime(2017, 1, 1), null, null);

            var changePointCountValues = new List <TemporalValueItem>
            {
                temporalValueItemOne,
                temporalValueItemTwo,
                temporalValueItemThree,
            };

            var attributeData = new AttributeData(null);

            attributeData.AddChangepoints(changePointCountValues);

            attributeData.Changepoints.Should().HaveCount(3);
            attributeData.Changepoints.Should().Contain(new[] { temporalValueItemOne, temporalValueItemTwo, temporalValueItemThree });
        }
Exemplo n.º 6
0
        public void SessionBuilder_SetAttribute_ChangePointValuesExist()
        {
            // ARRANGE
            var sessionBuilder = new SessionBuilder();
            var session        = MapToOPATestSession();
            var instance       = session.GetGlobalEntityInstance();
            var entity         = instance.GetEntity();

            var attributeData = new AttributeData(12345678);

            attributeData.AddChangepoints(TestChangePoints());

            // ACT
            sessionBuilder.SetAttribute(entity, instance, "UKPRN", attributeData);

            // ASSERT
            var ukprnChangePoint = entity.GetAttribute("UKPRN").GetValue(instance);

            ukprnChangePoint.Should().NotBeNull();
            ukprnChangePoint.ToString().Should().BeEquivalentTo("{unknown, 100.0 from 2017-08-01, 100.0 from 2017-09-01}");
        }