Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <CurrencyRepository> > loggerMoc = CurrencyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRepositoryMoc.GetContext();
            var repository = new CurrencyRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <CurrencyRepository> > loggerMoc = CurrencyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRepositoryMoc.GetContext();
            var repository = new CurrencyRepository(loggerMoc.Object, context);

            Currency entity = new Currency();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <CurrencyRepository> > loggerMoc = CurrencyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRepositoryMoc.GetContext();
            var      repository          = new CurrencyRepository(loggerMoc.Object, context);
            Currency entity = new Currency();

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

            await repository.Delete(entity.CurrencyCode);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <CurrencyRepository> > loggerMoc = CurrencyRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CurrencyRepositoryMoc.GetContext();
            var      repository          = new CurrencyRepository(loggerMoc.Object, context);
            Currency entity = new Currency();

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

            await repository.Update(new Currency());

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

            modifiedRecord.Should().NotBeNull();
        }