public async void Get()
        {
            Mock <ILogger <EventStatusRepository> > loggerMoc = EventStatusRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EventStatusRepositoryMoc.GetContext();
            var repository = new EventStatusRepository(loggerMoc.Object, context);

            EventStatus entity = new EventStatus();

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

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

            record.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <EventStatusRepository> > loggerMoc = EventStatusRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = EventStatusRepositoryMoc.GetContext();
            var         repository       = new EventStatusRepository(loggerMoc.Object, context);
            EventStatus entity           = new EventStatus();

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

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

            await repository.Update(record);

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

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

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

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

            await repository.Update(record);

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

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