public async void Get() { Mock <ILogger <TransactionStatusRepository> > loggerMoc = TransactionStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionStatusRepositoryMoc.GetContext(); var repository = new TransactionStatusRepository(loggerMoc.Object, context); TransactionStatus entity = new TransactionStatus(); context.Set <TransactionStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <TransactionStatusRepository> > loggerMoc = TransactionStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionStatusRepositoryMoc.GetContext(); var repository = new TransactionStatusRepository(loggerMoc.Object, context); TransactionStatus entity = new TransactionStatus(); context.Set <TransactionStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var modifiedRecord = context.Set <TransactionStatus>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }
public async void Update_Entity_Is_Tracked() { Mock <ILogger <TransactionStatusRepository> > loggerMoc = TransactionStatusRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = TransactionStatusRepositoryMoc.GetContext(); var repository = new TransactionStatusRepository(loggerMoc.Object, context); TransactionStatus entity = new TransactionStatus(); entity.SetProperties(default(int), "B"); context.Set <TransactionStatus>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); await repository.Update(record); var records = await context.Set <TransactionStatus>().ToListAsync(); records.Count.Should().Be(2); }