コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <DatabaseLogRepository> > loggerMoc = DatabaseLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DatabaseLogRepositoryMoc.GetContext();
            var repository = new DatabaseLogRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <DatabaseLogRepository> > loggerMoc = DatabaseLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DatabaseLogRepositoryMoc.GetContext();
            var repository = new DatabaseLogRepository(loggerMoc.Object, context);

            DatabaseLog entity = new DatabaseLog();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Delete()
        {
            Mock <ILogger <DatabaseLogRepository> > loggerMoc = DatabaseLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DatabaseLogRepositoryMoc.GetContext();
            var         repository       = new DatabaseLogRepository(loggerMoc.Object, context);
            DatabaseLog entity           = new DatabaseLog();

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

            await repository.Delete(entity.DatabaseLogID);

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

            modifiedRecord.Should().BeNull();
        }
コード例 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <DatabaseLogRepository> > loggerMoc = DatabaseLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = DatabaseLogRepositoryMoc.GetContext();
            var         repository       = new DatabaseLogRepository(loggerMoc.Object, context);
            DatabaseLog entity           = new DatabaseLog();

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

            await repository.Update(new DatabaseLog());

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

            modifiedRecord.Should().NotBeNull();
        }