Exemplo n.º 1
0
        public void ShouldReturnGames_ForPlatformType()
        {
            Game game = GetGameTestData();

            _unitOfWorkMock.Setup(m => m.Games.Find(It.IsAny <Expression <Func <Game, bool> > >()))
            .Returns(new List <Game> {
                game
            });

            IEnumerable <GameDto> result = _service.GetGamesByPlatformType("type");
            GameDto gameDto = result.First();

            Assert.IsTrue(gameDto.Equals(game.ToDto()));
        }
Exemplo n.º 2
0
        public void GetExistingGameForId()
        {
            var game = new Game()
            {
                Key = "key", Name = "name", Description = "description"
            };

            _unitOfWorkMock.Setup(m => m.Games.Get(It.IsAny <int>()))
            .Returns(game);

            GameDto gameDto = _service.Get(id: 1);

            Assert.IsTrue(gameDto.Equals(game.ToDto()));
        }
Exemplo n.º 3
0
        public void ShouldGetGame_ByKey()
        {
            var game = new Game()
            {
                Key = "key", Name = "name", Description = "description"
            };

            _unitOfWorkMock.Setup(m => m.Games.SingleOrDefault(It.IsAny <Expression <Func <Game, bool> > >()))
            .Returns(game);

            GameDto gameDto = _service.GetGameByKey("key");

            Assert.IsTrue(gameDto.Equals(game.ToDto()));
        }
Exemplo n.º 4
0
        public void ShouldEditGame()
        {
            var game = new Game()
            {
                Key           = "key",
                Name          = "name",
                Description   = "description",
                PlatformTypes = new List <PlatformType>(),
            };
            var gameDto = new GameDto
            {
                Key            = "key",
                LanguagesNames = new Dictionary <string, string> {
                    { "ru", "имя" }
                },
                LanguagesDescriptions = new Dictionary <string, string> {
                    { "ru", "описание" }
                }
            };
            var platformTypes = new List <PlatformType>
            {
                new PlatformType(),
                new PlatformType()
            };
            var publishers = new List <Publisher> {
                new Publisher()
            };
            var genres = new List <Genre> {
                new Genre()
            };

            _unitOfWorkMock
            .Setup(m => m.PlatformTypes.Find(It.IsAny <IPipeline <PlatformType> >()))
            .Returns(platformTypes);

            _unitOfWorkMock
            .Setup(m => m.Publishers.Find(It.IsAny <IPipeline <Publisher> >()))
            .Returns(publishers);

            _unitOfWorkMock
            .Setup(m => m.Genres.Find(It.IsAny <IPipeline <Genre> >()))
            .Returns(genres);

            _unitOfWorkMock
            .Setup(m => m.Games.Get(It.IsAny <int>()))
            .Returns(game);

            _service.Edit(
                gameId: 1,
                languagesNames: new Dictionary <string, string>()
            {
                { "ru", "имя" }
            },
                languagesDescriptions: new Dictionary <string, string>()
            {
                { "ru", "описание" }
            },
                price: 10,
                unitsInStock: 2,
                discounted: false,
                platformTypeIds: new List <int>()
            {
                1, 2
            },
                publisherIds: new List <int> {
                1
            },
                genreIds: new List <int> {
                1
            });

            Assert.IsTrue(gameDto.Equals(game.ToDto()));
        }
Exemplo n.º 5
0
        public void ShouldEditGame()
        {
            var game = new Game()
            {
                Key           = "key",
                Name          = "name",
                Description   = "description",
                PlatformTypes = new List <PlatformType>(),
            };
            var gameDto = new GameDto
            {
                Key            = "key",
                LanguagesNames = new Dictionary <string, string> {
                    { "ru", "имя" }
                },
                LanguagesDescriptions = new Dictionary <string, string> {
                    { "ru", "описание" }
                }
            };
            var platformTypes = new List <PlatformType>
            {
                new PlatformType(),
                new PlatformType()
            };
            var publishers = new List <Publisher> {
                new Publisher {
                    CompanyName = "CompanyName"
                }
            };
            var genres = new List <Genre> {
                new Genre()
            };

            _unitOfWorkMock
            .Setup(m => m.PlatformTypes.Find(It.IsAny <IPipeline <PlatformType> >()))
            .Returns(platformTypes);

            _unitOfWorkMock
            .Setup(m => m.Publishers.Find(It.IsAny <IPipeline <Publisher> >()))
            .Returns(publishers);

            _unitOfWorkMock
            .Setup(m => m.Genres.Find(It.IsAny <IPipeline <Genre> >()))
            .Returns(genres);

            _unitOfWorkMock
            .Setup(m => m.Games.Get(It.IsAny <int>()))
            .Returns(game);

            var editingGame = new EditingGameDto
            {
                GameId         = 1,
                LanguagesNames = new Dictionary <string, string>()
                {
                    { "ru", "имя" }
                },
                LanguagesDescriptions = new Dictionary <string, string>()
                {
                    { "ru", "описание" }
                },
                Price           = 10,
                UnitsInStock    = 2,
                Discounted      = false,
                PlatformTypeIds = new List <int>()
                {
                    1, 2
                },
                PublisherIds = new List <int>()
                {
                    1
                },
                GenreIds = new List <int>()
                {
                    1
                }
            };

            _service.Edit(editingGame);

            Assert.IsTrue(gameDto.Equals(game.ToDto()));
        }