Exemple #1
0
        public async void Create()
        {
            Mock <ILogger <CurrencyRateRepository> > loggerMoc = CurrencyRateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRateRepositoryMoc.GetContext();
            var repository = new CurrencyRateRepository(loggerMoc.Object, context);

            var entity = new CurrencyRate();
            await repository.Create(entity);

            var record = await context.Set <CurrencyRate>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
Exemple #2
0
        public async void Get()
        {
            Mock <ILogger <CurrencyRateRepository> > loggerMoc = CurrencyRateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRateRepositoryMoc.GetContext();
            var repository = new CurrencyRateRepository(loggerMoc.Object, context);

            CurrencyRate entity = new CurrencyRate();

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

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

            record.Should().NotBeNull();
        }
Exemple #3
0
        public async void Delete()
        {
            Mock <ILogger <CurrencyRateRepository> > loggerMoc = CurrencyRateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRateRepositoryMoc.GetContext();
            var          repository      = new CurrencyRateRepository(loggerMoc.Object, context);
            CurrencyRate entity          = new CurrencyRate();

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

            await repository.Delete(entity.CurrencyRateID);

            CurrencyRate modifiedRecord = await context.Set <CurrencyRate>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
Exemple #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <CurrencyRateRepository> > loggerMoc = CurrencyRateRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRateRepositoryMoc.GetContext();
            var          repository      = new CurrencyRateRepository(loggerMoc.Object, context);
            CurrencyRate entity          = new CurrencyRate();

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

            await repository.Update(new CurrencyRate());

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

            modifiedRecord.Should().NotBeNull();
        }