public void GetLatestTradeDate_WhenRepositoryHasNoTradeDates_ApplicationErrorFailureIsReturned() { // Arrange Mock <ITradeDateRepository> tradeDateRepository = new Mock <ITradeDateRepository>(); tradeDateRepository.Setup(r => r.GetLatestTradeDate()) .Returns(Maybe.Create <TradeDate>(null)); // Act TradeDateService service = new TradeDateService(tradeDateRepository.Object); var result = service.GetLatestTradeDate(); // Assert result.IsSuccess.Should().BeFalse(); result.Value.Should().BeNull(); result.Error.Should().BeOfType <ApplicationError>(); }
public void GetLatestTradeDate_WhenRepositoryReturnsLatestTradeDate_ItIsReturned() { // Arrange Mock <ITradeDateRepository> tradeDateRepository = new Mock <ITradeDateRepository>(); TradeDate tradeDate = new TradeDate(new DateTime(2018, 12, 31), true, true, true); tradeDateRepository.Setup(r => r.GetLatestTradeDate()) .Returns(Maybe.Create <TradeDate>(tradeDate)); // Act TradeDateService service = new TradeDateService(tradeDateRepository.Object); var result = service.GetLatestTradeDate(); // Assert result.IsSuccess.Should().BeTrue(); result.Value.Should().Be(tradeDate); }