예제 #1
0
        public async Task DeleteGuideShouldDelete()
        {
            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 model      = new CreateGuideInputModel()
            {
                Title       = "new",
                GameId      = "1",
                Category    = "Action",
                Description = "test",
                ImageUrl    = "google",
            };
            var modelId = await service.CreateAsync(model, "1");

            await service.DeleteGuideAsync(modelId);

            var actual = await service.GetAllCountAsync();

            Assert.Equal(0, actual);
        }