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