public async void Create() { Mock <ILogger <TransactionHistoryArchiveRepository> > loggerMoc = TransactionHistoryArchiveRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionHistoryArchiveRepositoryMoc.GetContext(); var repository = new TransactionHistoryArchiveRepository(loggerMoc.Object, context); var entity = new TransactionHistoryArchive(); await repository.Create(entity); var record = await context.Set <TransactionHistoryArchive>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <TransactionHistoryArchiveRepository> > loggerMoc = TransactionHistoryArchiveRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionHistoryArchiveRepositoryMoc.GetContext(); var repository = new TransactionHistoryArchiveRepository(loggerMoc.Object, context); TransactionHistoryArchive entity = new TransactionHistoryArchive(); context.Set <TransactionHistoryArchive>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.TransactionID); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <TransactionHistoryArchiveRepository> > loggerMoc = TransactionHistoryArchiveRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionHistoryArchiveRepositoryMoc.GetContext(); var repository = new TransactionHistoryArchiveRepository(loggerMoc.Object, context); TransactionHistoryArchive entity = new TransactionHistoryArchive(); context.Set <TransactionHistoryArchive>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.TransactionID); TransactionHistoryArchive modifiedRecord = await context.Set <TransactionHistoryArchive>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <TransactionHistoryArchiveRepository> > loggerMoc = TransactionHistoryArchiveRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionHistoryArchiveRepositoryMoc.GetContext(); var repository = new TransactionHistoryArchiveRepository(loggerMoc.Object, context); TransactionHistoryArchive entity = new TransactionHistoryArchive(); context.Set <TransactionHistoryArchive>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new TransactionHistoryArchive()); var modifiedRecord = context.Set <TransactionHistoryArchive>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }