public void Pledges_FundPledgesAtNonIntervalTimes_PledgeFundingExtendedFullInterval() { var firstFundingTime = _now; _pledges.Apply(new SetPledge(User1, PledgeAmount, firstFundingTime)); _pledges.Apply(new FundPledges(firstFundingTime.Plus(_settings.Frequency))); Clock.Advance(TimeSpan.FromHours(1)); var secondFundingTime = Clock.UnixUtcNow; var resp = _pledges.Apply(new FundPledges(secondFundingTime.Plus(_settings.Frequency))); resp.AssertStatusIs(ResponseStatus.Succeeded); Assert.AreEqual(firstFundingTime.Plus(_settings.Frequency * 2), _pledges.Get(User1).FundedThrough); Assert.AreEqual(User1StartBalance - _settings.RatePerUnit * PledgeAmount * 2, _accounts.Get(User1).Balance); }
public void TestMigrationProbabalistic() { var parameterDefinition = new Parameters(); parameterDefinition.ReadExcelFile("Parameter - Base.xlsm"); var p = parameterDefinition.GetBestGuess(); var m = FundModel.GetModel(); var res = m.Run(p); var c = new Clock(Timestep.FromYear(1951), Timestep.FromYear(2999)); while (!c.IsLastTimestep) { var regions = res.Dimensions.GetValues <Region>(); double totalLeave = (from r in regions select(double) res["ImpactSeaLevelRise", "leave"][c.Current, r]).Sum(); double totalEnter = (from r in regions select(double) res["ImpactSeaLevelRise", "enter"][c.Current, r]).Sum(); Assert.IsTrue(Math.Abs(totalLeave - totalEnter) < 1.0, "Migration doesn't even out"); c.Advance(); } }
public void TestMigrationDeterministic() { var parameterDefinition = new Parameters(); parameterDefinition.ReadExcelFile("Parameter - Base.xlsm"); var p = parameterDefinition.GetBestGuess(); var m = new Esmf.Model.ModelTyped <FundWorkflow>(); var res = m.Run(p); var c = new Clock(Timestep.FromYear(1951), Timestep.FromYear(2999)); while (!c.IsLastTimestep) { var regions = res.Dimensions.GetValues <Region>(); double totalLeave = (from r in regions select res.RootComponent.ImpactSeaLevelRise.leave[c.Current, r]).Sum(); double totalEnter = (from r in regions select res.RootComponent.ImpactSeaLevelRise.enter[c.Current, r]).Sum(); Assert.IsTrue(Math.Abs(totalLeave - totalEnter) < 1.0, "Migration doesn't even out"); c.Advance(); } }