public void ChangeOnSameDateAsExistingProperty() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change = new Date(2019, 12, 31); properties.Change(change, new EffectivePropertyTestClass("Change1")); properties.Change(change, new EffectivePropertyTestClass("Change2")); properties.Values.Should().SatisfyRespectively( first => { first.EffectivePeriod.Should().Be(new DateRange(change, Date.MaxValue)); first.Properties.Value.Should().Be("Change2"); }, second => { second.EffectivePeriod.Should().Be(new DateRange(start, change.AddDays(-1))); second.Properties.Value.Should().Be("InitialValue"); } ); }
public void PropertyAtDate(Date date, string result, bool exception) { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 15); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 12, 31); properties.Change(change2, new EffectivePropertyTestClass("Change2")); var end = new Date(2020, 01, 17); properties.End(end); if (!exception) { properties[date].Value.Should().Be(result); } else { Action a = () => { var x = properties[date]; }; a.Should().Throw <KeyNotFoundException>(); } }
public void EndWithProperties() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change = new Date(2019, 12, 31); properties.Change(change, new EffectivePropertyTestClass("Change1")); var end = new Date(2020, 01, 15); properties.End(end); properties.Values.Should().SatisfyRespectively( first => { first.EffectivePeriod.Should().Be(new DateRange(change, end)); first.Properties.Value.Should().Be("Change1"); }, second => { second.EffectivePeriod.Should().Be(new DateRange(start, change.AddDays(-1))); second.Properties.Value.Should().Be("InitialValue"); } ); }
public void Apply(StapledSecurityListedEvent @event) { Version++; Start(@event.ListingDate); var properties = new StockProperties(@event.AsxCode, @event.Name, @event.Category); _Properties.Change(@event.ListingDate, properties); _ChildSecurities = new StapledSecurityChild[@event.ChildSecurities.Length]; for (var i = 0; i < @event.ChildSecurities.Length; i++) { _ChildSecurities[i] = new StapledSecurityChild(@event.ChildSecurities[i].AsxCode, @event.ChildSecurities[i].Name, @event.ChildSecurities[i].Trust); } var dividendRules = new DividendRules(0.30m, RoundingRule.Round, false, DrpMethod.Round); _DividendRules.Change(@event.ListingDate, dividendRules); var percentages = new ApportionedCurrencyValue[_ChildSecurities.Length]; for (var i = 0; i < @event.ChildSecurities.Length; i++) { percentages[i].Units = 1; } MathUtils.ApportionAmount(1.00m, percentages); _RelativeNTAs.Change(@event.ListingDate, new RelativeNTA(percentages.Select(x => x.Amount).ToArray())); }
public Holding(IReadOnlyStock stock, Date fromDate) : base(stock.Id) { Stock = stock; Start(fromDate); _Properties.Change(fromDate, new HoldingProperties(0, 0.00m, 0.00m)); }
public void Apply(StockListedEvent @event) { Version++; Trust = @event.Trust; Start(@event.ListingDate); var properties = new StockProperties(@event.AsxCode, @event.Name, @event.Category); _Properties.Change(@event.ListingDate, properties); var dividendRules = new DividendRules(0.30m, RoundingRule.Round, false, DrpMethod.Round); _DividendRules.Change(@event.ListingDate, dividendRules); }
public void ChangeOutsideOfEffectivePeriod() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 31); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 11, 15); Action a = () => properties.Change(change2, new EffectivePropertyTestClass("Change2")); a.Should().Throw <EffectiveDateException>(); }
public void EndInNonCurrentPeriod() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 15); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 12, 31); properties.Change(change2, new EffectivePropertyTestClass("Change2")); var end = new Date(2019, 12, 17); Action a = () => properties.End(end); a.Should().Throw <EffectiveDateException>(); }
public void MatchesWithDateRange(DateRange dateRange, string value, bool result) { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 15); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 12, 31); properties.Change(change2, new EffectivePropertyTestClass("Change2")); var end = new Date(2020, 01, 17); properties.End(end); properties.Matches(dateRange, x => x.Value == value).Should().Be(result); }
public void ClosestToDate(Date date, string result) { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 15); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 12, 31); properties.Change(change2, new EffectivePropertyTestClass("Change2")); var end = new Date(2020, 01, 17); properties.End(end); properties.ClosestTo(date).Value.Should().Be(result); }
public void Value() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); var change1 = new Date(2019, 12, 15); properties.Change(change1, new EffectivePropertyTestClass("Change1")); var change2 = new Date(2019, 12, 31); properties.Change(change2, new EffectivePropertyTestClass("Change2")); var end = new Date(2020, 01, 17); properties.End(end); properties.Value(new Date(2019, 12, 17)).EffectivePeriod.Should().Be(new DateRange(new Date(2019, 12, 15), new Date(2019, 12, 30))); }
public void ChangeWithNoExistingProperties() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); properties.Values.Should().SatisfyRespectively( first => { first.EffectivePeriod.Should().Be(new DateRange(start, Date.MaxValue)); first.Properties.Value.Should().Be("InitialValue"); } ); }
public void EndOnStartDate() { var properties = new EffectiveProperties <EffectivePropertyTestClass>(); var start = new Date(2019, 12, 01); properties.Change(start, new EffectivePropertyTestClass("InitialValue")); properties.End(start); properties.Values.Should().SatisfyRespectively( first => { first.EffectivePeriod.Should().Be(new DateRange(start, start)); first.Properties.Value.Should().Be("InitialValue"); } ); }