Esempio n. 1
0
        public async void Get()
        {
            Mock <ILogger <RateRepository> > loggerMoc = RateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext             context   = RateRepositoryMoc.GetContext();
            var repository = new RateRepository(loggerMoc.Object, context);

            Rate entity = new Rate();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <RateRepository> > loggerMoc = RateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext             context   = RateRepositoryMoc.GetContext();
            var  repository = new RateRepository(loggerMoc.Object, context);
            Rate entity     = new Rate();

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <RateRepository> > loggerMoc = RateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext             context   = RateRepositoryMoc.GetContext();
            var  repository = new RateRepository(loggerMoc.Object, context);
            Rate entity     = new Rate();

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

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

            await repository.Update(record);

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

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