Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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();
        }
Beispiel #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();
        }