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