Esempio n. 1
0
        public async void Create()
        {
            Mock <ILogger <ErrorLogRepository> > loggerMoc = ErrorLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ErrorLogRepositoryMoc.GetContext();
            var repository = new ErrorLogRepository(loggerMoc.Object, context);

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

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

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

            ErrorLog entity = new ErrorLog();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Delete()
        {
            Mock <ILogger <ErrorLogRepository> > loggerMoc = ErrorLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ErrorLogRepositoryMoc.GetContext();
            var      repository          = new ErrorLogRepository(loggerMoc.Object, context);
            ErrorLog entity = new ErrorLog();

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

            await repository.Delete(entity.ErrorLogID);

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

            modifiedRecord.Should().BeNull();
        }
Esempio n. 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ErrorLogRepository> > loggerMoc = ErrorLogRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ErrorLogRepositoryMoc.GetContext();
            var      repository          = new ErrorLogRepository(loggerMoc.Object, context);
            ErrorLog entity = new ErrorLog();

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

            await repository.Update(new ErrorLog());

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

            modifiedRecord.Should().NotBeNull();
        }