Пример #1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <FollowerRepository> > loggerMoc = FollowerRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = FollowerRepositoryMoc.GetContext();
            var      repository          = new FollowerRepository(loggerMoc.Object, context);
            Follower entity = new Follower();

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

            await repository.Update(new Follower());

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

            modifiedRecord.Should().NotBeNull();
        }
Пример #2
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <FollowerRepository> > loggerMoc = FollowerRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = FollowerRepositoryMoc.GetContext();
            var      repository          = new FollowerRepository(loggerMoc.Object, context);
            Follower entity = new Follower();

            entity.SetProperties(default(int), "B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B");
            context.Set <Follower>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

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