public void GetHistoricalRateEndpointShouldReturnSuccessFalseOnException() { //ARRANGE var currencyLayerApiProviderMock = new Mock <ICurrencyLayerApiProvider>(MockBehavior.Strict); currencyLayerApiProviderMock.Setup(x => x.GetHistoricalRatesForGivenCurrency(It.IsAny <string>(), It.IsAny <DateTime>())).Throws(new Exception()); string currency = "USD"; //ACT var controller = new HistoricalRateProcessor(currencyLayerApiProviderMock.Object); var result = controller.GetHistoricalRatesForGivenCurrency(currency); //ASSERT Assert.Equal(false, result.Success); }
public void GetHistoricalRateEndpointShouldReturnSuccessFalseOnEmptyQuotes() { //ARRANGE var currencyLayerApiProviderMock = new Mock <ICurrencyLayerApiProvider>(MockBehavior.Strict); var apiResponseMock = new HistoricalRateApiResult(); apiResponseMock.Success = true; apiResponseMock.Quotes = new Dictionary <string, decimal>(); currencyLayerApiProviderMock.Setup(x => x.GetHistoricalRatesForGivenCurrency(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(apiResponseMock); string currency = "USD"; //ACT var controller = new HistoricalRateProcessor(currencyLayerApiProviderMock.Object); var result = controller.GetHistoricalRatesForGivenCurrency(currency); //ASSERT Assert.Equal(false, result.Success); }
public void GetHistoricalRateEndpointShouldNotReturnSuccessMessageOnFailure() { //ARRANGE var currencyLayerApiProviderMock = new Mock <ICurrencyLayerApiProvider>(MockBehavior.Strict); var apiResponseMock = new HistoricalRateApiResult(); apiResponseMock.Success = false; apiResponseMock.Quotes = new Dictionary <string, decimal>(); apiResponseMock.Quotes.Add("teste", 9.0m); currencyLayerApiProviderMock.Setup(x => x.GetHistoricalRatesForGivenCurrency(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(apiResponseMock); string currency = "USD"; //ACT var controller = new HistoricalRateProcessor(currencyLayerApiProviderMock.Object); var result = controller.GetHistoricalRatesForGivenCurrency(currency); //ASSERT Assert.NotEqual("Successful Operation", result.Message); }
public void GetHistoricalRateEndpointShouldReturnAllSevenQuotesWithCorrectValuesOnSuccess() { //ARRANGE var currencyLayerApiProviderMock = new Mock <ICurrencyLayerApiProvider>(MockBehavior.Strict); var apiResponseMock = new HistoricalRateApiResult(); apiResponseMock.Success = true; apiResponseMock.Quotes = new Dictionary <string, decimal>(); apiResponseMock.Quotes.Add("teste", 9.0m); currencyLayerApiProviderMock.Setup(x => x.GetHistoricalRatesForGivenCurrency(It.IsAny <string>(), It.IsAny <DateTime>())).Returns(apiResponseMock); string currency = "USD"; //ACT var controller = new HistoricalRateProcessor(currencyLayerApiProviderMock.Object); var result = controller.GetHistoricalRatesForGivenCurrency(currency); //ASSERT foreach (List <double> innerResult in result.Quotes) { Assert.Equal(2, innerResult.Count); Assert.True(innerResult.Contains(9.0)); } }