Exemple #1
0
        public void GenerateKeyAsync_AddsNumberToKey_WhenExistsSameKey()
        {
            const string expectedKey       = "grand4";
            const string input             = "Grand";
            var          testGamesSequence = CreateGameRoots();

            A.CallTo(() => _gameDecorator.AnyAsync(A <Expression <Func <GameRoot, bool> > > ._))
            .Returns(true);
            A.CallTo(() => _gameDecorator.FindAllAsync(A <Expression <Func <GameRoot, bool> > > ._))
            .Returns(testGamesSequence);

            var key = _gameServices.GenerateKeyAsync(input, Separator).Result;

            key.Should().BeEquivalentTo(expectedKey);
        }
Exemple #2
0
        public async Task <IEnumerable <GameDto> > GetAllAsync(string culture = Culture.En)
        {
            var games = await _gameDecorator.FindAllAsync(new GameFilterData());

            var gamesDto = new List <GameDto>();

            foreach (var game in games)
            {
                var gameDto = await GetGameDtoAsync(game, culture);

                gamesDto.Add(gameDto);
            }

            return(gamesDto);
        }
Exemple #3
0
        private async Task SetupGameDetailsAsync(params Order[] orders)
        {
            var orderDetails = orders.SelectMany(o => o.Details);
            var keys         = orderDetails.Select(od => od.GameRoot.Key).ToList();
            var roots        = await _gameDecorator.FindAllAsync(new GameFilterData { Keys = keys });

            foreach (var details in orderDetails)
            {
                details.GameRoot = roots.FirstOrDefault(r => r.Id == details.GameRootId);
            }
        }
Exemple #4
0
        public void FindSingleAsync_ReturnOrderWithInitializedGameDetails_WhenFound()
        {
            var testOrder = CreateOrder();
            var gameRoot  = new GameRoot {
                Id = Id
            };

            testOrder.Details = new[] { CreateDetails() };
            A.CallTo(() => _sqlOrderRepository.FindSingleAsync(_testExpression)).Returns(testOrder);
            A.CallTo(() => _gameDecorator.FindAllAsync(A <GameFilterData> ._)).Returns(new[] { gameRoot });

            var order = _orderDecorator.FindSingleAsync(_testExpression).Result;

            order.Details.First().GameRoot.Should().Be(gameRoot);
        }