Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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));
            }
        }