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

            Country entity = new Country();

            context.Set <Country>().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 <CountryRepository> > loggerMoc = CountryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CountryRepositoryMoc.GetContext();
            var     repository           = new CountryRepository(loggerMoc.Object, context);
            Country entity = new Country();

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

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

            await repository.Update(record);

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

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

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

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

            await repository.Update(record);

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

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