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