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

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
        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();
        }
Exemplo n.º 3
0
        public async void Create()
        {
            Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext();
            var repository = new PostHistoryRepository(loggerMoc.Object, context);

            var entity = new PostHistory();
            await repository.Create(entity);

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

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <PostHistoryRepository> > loggerMoc = PostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostHistoryRepositoryMoc.GetContext();
            var repository = new PostHistoryRepository(loggerMoc.Object, context);

            var entity = new PostHistory();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B", "B", 1);
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
Exemplo n.º 5
0
        public async void Get()
        {
            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();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
        public async void Get()
        {
            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();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            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.Update(new PostHistory());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            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();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

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

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