Пример #1
0
        public async void Get()
        {
            Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext();
            var repository = new TimestampCheckRepository(loggerMoc.Object, context);

            TimestampCheck entity = new TimestampCheck();

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <TimestampCheckRepository> > loggerMoc = TimestampCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TimestampCheckRepositoryMoc.GetContext();
            var            repository    = new TimestampCheckRepository(loggerMoc.Object, context);
            TimestampCheck entity        = new TimestampCheck();

            entity.SetProperties(default(int), "B", BitConverter.GetBytes(2));
            context.Set <TimestampCheck>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(record);

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

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