public void AddTransformation() { var action = new RestApi.CorporateActions.Transformation() { Id = Guid.NewGuid(), Stock = _StockWithoutCorporateActions, ActionDate = new Date(2001, 01, 01), Description = "Transformation", ImplementationDate = new Date(2001, 01, 15), CashComponent = 10.15m, RolloverRefliefApplies = true }; action.ResultingStocks.Add(new RestApi.CorporateActions.Transformation.ResultingStock() { Stock = _StockWithCorporateActions, AquisitionDate = new Date(2001, 04, 01), CostBase = 0.50m, OriginalUnits = 1, NewUnits = 2 }); var result = _Service.AddCorporateAction(_StockWithoutCorporateActions, action); result.Should().HaveOkStatus(); var resultStocks = new TransformationAddedEvent.ResultingStock(_StockWithCorporateActions, 1, 2, 0.50m, new Date(2001, 04, 01)); _Events.Should().BeEquivalentTo(new[] { new TransformationAddedEvent(_StockWithoutCorporateActions, 1, action.Id, new Date(2001, 01, 01), "Transformation", new Date(2001, 01, 15), 10.15m, true, new [] { resultStocks }) }); }
public void ApplyTransformationAddedEvent() { var mockRepository = new MockRepository(MockBehavior.Strict); var stock = new Stock(Guid.NewGuid()); stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks); var stock2 = new Stock(Guid.NewGuid()); stock2.List("XYZ", "XYZ Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks); var events = mockRepository.Create <IEventList>(); var corporateActionList = new CorporateActionList(stock, events.Object); var id = Guid.NewGuid(); var resultStocks = new TransformationAddedEvent.ResultingStock[] { new TransformationAddedEvent.ResultingStock(stock2.Id, 1, 2, 0.40m, new Date(2020, 02, 01)) }; var @event = new TransformationAddedEvent(stock.Id, 0, id, new Date(2000, 01, 01), "Test Transformation", new Date(2000, 02, 01), 1.20m, false, resultStocks); corporateActionList.Apply(@event); corporateActionList.Should().SatisfyRespectively( first => { first.Should().BeEquivalentTo(new { Id = id, Stock = stock, Date = new Date(2000, 01, 01), Description = "Test Transformation", CashComponent = 1.20M, RolloverRefliefApplies = false }); first.Should().BeOfType <Transformation>().Which.ResultingStocks.Should().HaveCount(1); } ); mockRepository.Verify(); }