Esempio n. 1
0
        public async Task Handle_ResponseOrderedByAbbreviation()
        {
            var bitcoinPriceService = BitcoinPriceServiceFactory.Create();
            var dictionary          = BitcoinPriceServiceFactory.GetDictionary();
            var mapper  = AutoMapperFactory.Create();
            var handler = new GetAllCurrenciesQuery.Handler(bitcoinPriceService.Object,
                                                            mapper);

            var res =
                await handler.Handle(new GetAllCurrenciesQuery(), CancellationToken.None);

            Assert.Equal(dictionary.OrderBy(x => x.Key).First().Key, res.Data.First().Abbreviation);
        }
Esempio n. 2
0
        public async Task Handle_ReturnsResponse()
        {
            var bitcoinPriceService = BitcoinPriceServiceFactory.Create();
            var dictionary          = BitcoinPriceServiceFactory.GetDictionary();
            var mapper  = AutoMapperFactory.Create();
            var handler = new GetAllCurrenciesQuery.Handler(bitcoinPriceService.Object,
                                                            mapper);

            var res =
                await handler.Handle(new GetAllCurrenciesQuery(), CancellationToken.None);

            Assert.Equal(dictionary.Count, res.Count);
            Assert.Equal(dictionary.Count, res.Data.Count);
        }
        public async Task Handle_ReturnsResponse()
        {
            var dictionary          = BitcoinPriceServiceFactory.GetDictionary();
            var bitcoinPriceService = BitcoinPriceServiceFactory.Create();

            var handler = new GetAllCurrencyAbbreviationsQuery.Handler(bitcoinPriceService.Object);

            var res =
                await handler.Handle(new GetAllCurrencyAbbreviationsQuery(),
                                     CancellationToken.None);

            Assert.Equal(dictionary.Count, res.Count);
            Assert.Equal(dictionary.OrderBy(x => x.Key).First().Key,
                         res.First());
        }
Esempio n. 4
0
        public void Map_MappingsCorrect()
        {
            var dictionary = BitcoinPriceServiceFactory.GetDictionary();

            var(abbreviation, currencyResponse) = dictionary.First();

            var keyValuePair = dictionary.First();
            var mapper       = AutoMapperFactory.Create();

            var res = mapper.Map <CurrencyDto>(keyValuePair);

            Assert.Equal(abbreviation, res.Abbreviation);
            Assert.Equal(currencyResponse._15m, res._15m);
            Assert.Equal(currencyResponse.Last, res.Last);
            Assert.Equal(currencyResponse.Buy, res.Buy);
            Assert.Equal(currencyResponse.Sell, res.Sell);
            Assert.Equal(currencyResponse.Symbol, res.Symbol);
        }
Esempio n. 5
0
        public void Map_MappingsCorrect()
        {
            var dictionary = BitcoinPriceServiceFactory
                             .GetDictionary()
                             .OrderBy(x => x.Key)
                             .AsEnumerable();
            var abbreviation     = dictionary.First().Key;
            var currencyResponse = dictionary.First().Value;

            var mapper = AutoMapperFactory.Create();

            var res   = mapper.Map <CurrencyVm>(dictionary);
            var first = res.Data.First();

            Assert.Equal(dictionary.AsEnumerable().Count(), res.Count);
            Assert.Equal(abbreviation, first.Abbreviation);
            Assert.Equal(currencyResponse._15m, first._15m);
            Assert.Equal(currencyResponse.Last, first.Last);
            Assert.Equal(currencyResponse.Buy, first.Buy);
            Assert.Equal(currencyResponse.Sell, first.Sell);
            Assert.Equal(currencyResponse.Symbol, first.Symbol);
        }