public async Task ExceptionIfNotFutureInstrument() { //Arrange mockFuturesDataService .Setup(s => s.GetCurrentDayFutureInstrumentDataAsync(It.IsAny <string>())) .ReturnsAsync(new FutureInstrumentResponse { SymbolName = "INFY", IsFNOSecurity = false, Details = new List <InstrumentDetail> { new InstrumentDetail { InstrumentType = "Stock Futures", ExpiryDate = new DateTime(2020, 5, 28) }, new InstrumentDetail { InstrumentType = "Stock Options", ExpiryDate = new DateTime(2020, 5, 28) } } }); //Act var sut = new GetTodaysInstrumentInfoQueryHandler(mockFuturesDataService.Object); Func <Task <FutureInstrumentInfoVM> > func = async() => await sut.Handle(new GetTodaysInstrumentInfoQuery { SymbolName = "INFY", ContractExpiryDate = new DateTime(2020, 5, 28) }, new CancellationToken()); //Assert await func.Should().ThrowAsync <NoRecordsFoundException>() .WithMessage("Given symbol doesn't belong to futures instrument"); }
public async Task ReturnValidResultIfCorrectInputPassed() { //Arrange mockFuturesDataService .Setup(s => s.GetCurrentDayFutureInstrumentDataAsync(It.IsAny <string>())) .ReturnsAsync(new FutureInstrumentResponse { SymbolName = "INFY", IsFNOSecurity = true, Details = new List <InstrumentDetail> { new InstrumentDetail { InstrumentType = "Stock Futures", ExpiryDate = new DateTime(2020, 5, 28) }, new InstrumentDetail { InstrumentType = "Stock Options", ExpiryDate = new DateTime(2020, 5, 28) } } }); //Act var sut = new GetTodaysInstrumentInfoQueryHandler(mockFuturesDataService.Object); var output = await sut.Handle(new GetTodaysInstrumentInfoQuery { SymbolName = "INFY", ContractExpiryDate = new DateTime(2020, 5, 28) }, new CancellationToken()); //Assert using (new AssertionScope()) { output.SymbolName.Should().Be("INFY"); } }