public void DeleteNotFound()
        {
            Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext();
            var repository = new PostHistoryRepository(loggerMoc.Object, context);

            Func <Task> delete = async() =>
            {
                await repository.Delete(default(int));
            };

            delete.Should().NotThrow();
        }
Пример #2
0
        public async void Delete()
        {
            Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext();
            var         repository       = new PostHistoryRepository(loggerMoc.Object, context);
            PostHistory entity           = new PostHistory();

            context.Set <PostHistory>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            PostHistory modifiedRecord = await context.Set <PostHistory>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
        public async void DeleteFound()
        {
            Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext();
            var         repository       = new PostHistoryRepository(loggerMoc.Object, context);
            PostHistory entity           = new PostHistory();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1);
            context.Set <PostHistory>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            var records = await context.Set <PostHistory>().ToListAsync();

            records.Count.Should().Be(1);
        }