コード例 #1
0
        public async void Get()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);

            Pet entity = new Pet();

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

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

            record.Should().NotBeNull();
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);

            Pet entity = new Pet();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <PetRepository> > loggerMoc = PetRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext            context   = PetRepositoryMoc.GetContext();
            var repository = new PetRepository(loggerMoc.Object, context);
            Pet entity     = new Pet();

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }