コード例 #1
0
        public async Task WhenManagerReturnsCurrentRates_ThenResponseIsUsedToBuildDto()
        {
            var currentRates = new ExchangeRatesResponse("EUR", DateTime.Now, new Dictionary <string, decimal>());

            var manager = new Mock <IExchangeRatesManager>();

            manager.Setup(m => m.GetLatestRates()).ReturnsAsync(currentRates);

            ExchangeRatesResponse buildDtoInput = null;

            var dtoFactory = new Mock <IExchangeRatesDtoFactory>();

            dtoFactory.Setup(m => m.BuildDto(It.IsAny <ExchangeRatesResponse>()))
            .Callback <ExchangeRatesResponse>(input => buildDtoInput = input)
            .Returns(new ExchangeRatesResponseDto(
                         "base",
                         DateTime.UtcNow,
                         new Dictionary <string, decimal>()));

            var controller = new ExchangeRatesController(manager.Object, dtoFactory.Object);

            await controller.Index();

            buildDtoInput.Should().Be(currentRates);
        }
コード例 #2
0
        public void WhenTwoResponsesHaveTheSameBaseAndDate_ThenTheyAreEquivalent()
        {
            var baseCurrency = "BASE";
            var date         = DateTime.UtcNow;

            var response1 = new ExchangeRatesResponse(baseCurrency, date, new Dictionary <string, decimal>());
            var response2 = new ExchangeRatesResponse(baseCurrency, date, new Dictionary <string, decimal>());

            response1.Should().BeEquivalentTo(response2);
        }