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