public async Task <Either <Error, Nothing> > Handle(Command command, CancellationToken cancellationToken) { var dateLag = new DateLag(command.DateLag); var instrumentResult = await FromId(command.InstrumentId.NonEmpty(), GetVendor); return(await Handle(cancellationToken, command.MarketCurveId.NonEmpty(), whatToDo : c => instrumentResult.MapRight(instrument => c.AddCurvePoint(command.Tenor, instrument, dateLag, command.PriceType, command.IsMandatory)))); }
private static Either <Error, PointRecipe> TryMap(ICurvePointAdded e) { var priceTypeResult = e.PriceType.TryParseOptionalEnum <PriceType>(); var tenorResult = e.Tenor.TryParseEnum <Tenor>(); return(priceTypeResult.MapRight(tenorResult, (p, t) => { var dateLag = new DateLag(e.DateLag); return new PointRecipe(e.InstrumentId, t, dateLag, p); })); }
public void UT_MarketCurve_AddCurvePoint_happy_flow() { var id = Guid.NewGuid(); var tenor = Tenor.FRA10x16; var instrument = new Instrument(NonEmpty.Guid(), Vendor.Bloomberg); var dateLag = new DateLag(-1); var priceType = PriceType.BIDPRICE; var isMandatory = false; Given(MarketCurveCreated(Country.GB, CurveType.ECB)) .When(c => c.AddCurvePoint(tenor, instrument, dateLag, priceType, isMandatory)) .Then(CurvePointAdded(tenor, instrument.Id, dateLag.Value, isMandatory, priceType)); }