示例#1
0
        public async void Get()
        {
            Mock <ILogger <OtherTransportRepository> > loggerMoc = OtherTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = OtherTransportRepositoryMoc.GetContext();
            var repository = new OtherTransportRepository(loggerMoc.Object, context);

            OtherTransport entity = new OtherTransport();

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

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

            record.Should().NotBeNull();
        }
示例#2
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <OtherTransportRepository> > loggerMoc = OtherTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = OtherTransportRepositoryMoc.GetContext();
            var            repository    = new OtherTransportRepository(loggerMoc.Object, context);
            OtherTransport entity        = new OtherTransport();

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }
示例#3
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <OtherTransportRepository> > loggerMoc = OtherTransportRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = OtherTransportRepositoryMoc.GetContext();
            var            repository    = new OtherTransportRepository(loggerMoc.Object, context);
            OtherTransport entity        = new OtherTransport();

            entity.SetProperties(default(int), 1, 1);
            context.Set <OtherTransport>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(record);

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

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