Esempio n. 1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <BadgeRepository> > loggerMoc = BadgeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BadgeRepositoryMoc.GetContext();
            var   repository             = new BadgeRepository(loggerMoc.Object, context);
            Badge entity = new Badge();

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

            await repository.Update(new Badge());

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

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <BadgeRepository> > loggerMoc = BadgeRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = BadgeRepositoryMoc.GetContext();
            var   repository             = new BadgeRepository(loggerMoc.Object, context);
            Badge entity = new Badge();

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

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

            await repository.Update(entity);

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

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