public async Task GetPastMonthRates() { var pastDate = DateTime.Now.AddMonths(-3); var currencies = new[] { new Currency { Id = Guid.NewGuid(), Code = "USD", Description = "US Dollar", Symbol = "$", DefaultCurrency = true }, new Currency { Id = Guid.NewGuid(), Code = "AUD", Description = "Australian Dollar", Symbol = "$" }, new Currency { Id = Guid.NewGuid(), Code = "CAD", Description = "Canadian Dollar", Symbol = "$" } }; var exchangeRates = new List <ExchangeRate> { new ExchangeRate { FromCurrency = currencies[1].Id, ToCurrency = currencies[0].Id, EffectiveFrom = DateTime.UtcNow, Rate = decimal.Parse("1.31") }, new ExchangeRate { FromCurrency = currencies[2].Id, ToCurrency = currencies[0].Id, EffectiveFrom = pastDate, Rate = decimal.Parse("0.715") } }; _dbContext.MockAsyncQueryable(exchangeRates.AsQueryable(), c => c.ExchangeRate); _dbContext.MockAsyncQueryable(currencies.AsQueryable(), c => c.Currency); var result = await _service.GetPastRates(pastDate); var cadExRate = result.Single(x => x.FromCurrency == currencies[2].Id); cadExRate.Rate.Should().Be(decimal.Parse("0.715")); cadExRate.EffectiveFrom.Should().Be(pastDate); }