예제 #1
0
        public async Task GetAllShouldGetFive()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var context = new ApplicationDbContext(options.Options);
            await context.Users.AddAsync(new ApplicationUser()
            {
                Id = "1"
            });

            await context.Games.AddAsync(new Game()
            {
                Id = "1"
            });

            var repository = new EfDeletableEntityRepository <Guide>(context);
            var service    = new GuidesService(repository);
            var models     = new List <CreateGuideInputModel>()
            {
                new CreateGuideInputModel()
                {
                    Title       = "new",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test",
                    ImageUrl    = "google",
                },
                new CreateGuideInputModel()
                {
                    Title       = "new2",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test2",
                    ImageUrl    = "google2",
                },
                new CreateGuideInputModel()
                {
                    Title       = "new3",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test3",
                    ImageUrl    = "google3",
                },
                new CreateGuideInputModel()
                {
                    Title       = "new4",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test4",
                    ImageUrl    = "google4",
                },
                new CreateGuideInputModel()
                {
                    Title       = "new5",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test5",
                    ImageUrl    = "google5",
                },
                new CreateGuideInputModel()
                {
                    Title       = "new6",
                    GameId      = "1",
                    Category    = "Action",
                    Description = "test6",
                    ImageUrl    = "google6",
                },
            };

            foreach (var model in models)
            {
                await service.CreateAsync(model, "1");
            }

            var actual = await service.GetAllAsync <GuideViewModel>(5, 0);

            Assert.Equal(5, actual.Count());
        }