public void OnlineDeviceStateMachineTest() { var startdate = new DateTime(2018, 1, 1); var enddate = startdate.AddMinutes(200); CalcParameters calcParameters = CalcParametersFactory.MakeGoodDefaults() .SetStartDate(startdate).SetEndDate(enddate).SetSettlingDays(0).EnableShowSettlingPeriod(); var values = new double[10]; for (var i = 0; i < values.Length; i++) { values[i] = i + 1; Logger.Info(values[i].ToString(CultureInfo.CurrentCulture)); } var valueList = new List <double>(values); var r = new Random(1); var nr = new NormalRandom(0, 1, r); var devGuid = Guid.NewGuid().ToStrGuid(); var locGuid = Guid.NewGuid().ToStrGuid(); var clt = new CalcLoadType("lt", "kWh", "W", 1, true, Guid.NewGuid().ToStrGuid()); var calcDeviceDto = new CalcDeviceDto("device", devGuid, new HouseholdKey("hh1"), OefcDeviceType.Device, "mycategory", "", devGuid, locGuid, "locname"); var key = new OefcKey(calcDeviceDto, locGuid); var cp = new CalcProfile("mycalcprofile", Guid.NewGuid().ToStrGuid(), valueList, ProfileType.Absolute, "bla"); TimeStep ts = new TimeStep(5, 0, false); CalcDeviceLoad cdl = new CalcDeviceLoad("", 1, clt, 0, 0); StepValues sv = StepValues.MakeStepValues(cp, 1, RandomValueProfile.MakeStepValues(cp.StepValues.Count, nr, 0), cdl); var odsm = new OnlineDeviceStateMachine(ts, clt.ConvertToDto(), "device", key, "affordance", calcParameters, sv, 0); calcParameters.SetDummyTimeSteps(0); odsm.CalculateOfficialEnergyUse().Should().Be(55); // all calcParameters.SetDummyTimeSteps(6); odsm.CalculateOfficialEnergyUse().Should().Be(54); // not the first //_calcParameters.InternalTimesteps = 20; calcParameters.SetDummyTimeSteps(15); odsm.CalculateOfficialEnergyUse().Should().Be(0); // none calcParameters.SetDummyTimeSteps(14); odsm.CalculateOfficialEnergyUse().Should().Be(10); // only the last Logger.Info(odsm.CalculateOfficialEnergyUse().ToString(CultureInfo.CurrentCulture)); startdate = new DateTime(2018, 1, 1); enddate = startdate.AddMinutes(10); calcParameters.DisableShowSettlingPeriod(); calcParameters.SetStartDate(startdate).SetEndDate(enddate) .SetDummyTimeSteps(5); odsm.CalculateOfficialEnergyUse().Should().Be(15); // only the first 5 //_calcParameters.InternalTimesteps = 10; // only 5 calcParameters.SetDummyTimeSteps(9); var val = odsm.CalculateOfficialEnergyUse(); val.Should().Be(5); // only #5 Logger.Info(odsm.CalculateOfficialEnergyUse().ToString(CultureInfo.CurrentCulture)); }