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