Ejemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <PostTypesRepository> > loggerMoc = PostTypesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostTypesRepositoryMoc.GetContext();
            var repository = new PostTypesRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <PostTypesRepository> > loggerMoc = PostTypesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostTypesRepositoryMoc.GetContext();
            var repository = new PostTypesRepository(loggerMoc.Object, context);

            PostTypes entity = new PostTypes();

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

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

            record.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <PostTypesRepository> > loggerMoc = PostTypesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostTypesRepositoryMoc.GetContext();
            var       repository         = new PostTypesRepository(loggerMoc.Object, context);
            PostTypes entity             = new PostTypes();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Ejemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <PostTypesRepository> > loggerMoc = PostTypesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = PostTypesRepositoryMoc.GetContext();
            var       repository         = new PostTypesRepository(loggerMoc.Object, context);
            PostTypes entity             = new PostTypes();

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

            await repository.Update(new PostTypes());

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

            modifiedRecord.Should().NotBeNull();
        }