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

            Species entity = new Species();

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

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }
예제 #3
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <SpeciesRepository> > loggerMoc = SpeciesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpeciesRepositoryMoc.GetContext();
            var     repository           = new SpeciesRepository(loggerMoc.Object, context);
            Species entity = new Species();

            entity.SetProperties(default(int), "B");
            context.Set <Species>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(record);

            var records = await context.Set <Species>().ToListAsync();

            records.Count.Should().Be(2);
        }