예제 #1
0
        public async void Create()
        {
            Mock <ILogger <StateRepository> > loggerMoc = StateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StateRepositoryMoc.GetContext();
            var repository = new StateRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <StateRepository> > loggerMoc = StateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StateRepositoryMoc.GetContext();
            var repository = new StateRepository(loggerMoc.Object, context);

            State entity = new State();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <StateRepository> > loggerMoc = StateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StateRepositoryMoc.GetContext();
            var   repository             = new StateRepository(loggerMoc.Object, context);
            State entity = new State();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <StateRepository> > loggerMoc = StateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = StateRepositoryMoc.GetContext();
            var   repository             = new StateRepository(loggerMoc.Object, context);
            State entity = new State();

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

            await repository.Update(new State());

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

            modifiedRecord.Should().NotBeNull();
        }