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

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

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

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

            Configuration entity = new Configuration();

            context.Set <Configuration>().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 <ConfigurationRepository> > loggerMoc = ConfigurationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ConfigurationRepositoryMoc.GetContext();
            var           repository     = new ConfigurationRepository(loggerMoc.Object, context);
            Configuration entity         = new Configuration();

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new Configuration());

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

            modifiedRecord.Should().NotBeNull();
        }