public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var             repository   = new RowVersionCheckRepository(loggerMoc.Object, context);
            RowVersionCheck entity       = new RowVersionCheck();

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

            await repository.Update(new RowVersionCheck());

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

            modifiedRecord.Should().NotBeNull();
        }
Example #2
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <RowVersionCheckRepository> > loggerMoc = RowVersionCheckRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = RowVersionCheckRepositoryMoc.GetContext();
            var             repository   = new RowVersionCheckRepository(loggerMoc.Object, context);
            RowVersionCheck entity       = new RowVersionCheck();

            entity.SetProperties(default(int), "B", Guid.Parse("3842cac4-b9a0-8223-0dcc-509a6f75849b"));
            context.Set <RowVersionCheck>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

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

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