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

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

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

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

            VariableSet entity = new VariableSet();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new VariableSet());

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

            modifiedRecord.Should().NotBeNull();
        }