예제 #1
0
        public async Task EditGuideShouldEditContent()
        {
            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 guideId = await service.CreateAsync(model, "1");

            var oldGuide = await service.GetByIdAsync <EditGuideViewModel>(guideId);

            var contentOldValue = oldGuide.Content;

            await service.EditGuideAsync(oldGuide.Id, oldGuide.Title, "newwwwwwwwwwwwwwwwwwwwwwwwwwwww");

            var newGuide = await service.GetByIdAsync <EditGuideViewModel>(guideId);

            Assert.NotEqual(contentOldValue, newGuide.Title);
        }