public void ThrowArgumentNullException_WhenDbContextParameterIsNull() { IProgrammersSpotDbContext nullContext = null; Assert.That( () => new ProgrammersSpot.Business.Data.UnitOfWork.UnitOfWork(nullContext), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains("Db context")); }
public void ShouldThrowArgumentNullException_WhenDbContextIsNull() { // Arrange IProgrammersSpotDbContext nullDbContext = null; // Act & Assert Assert.That(() => new GenericRepository <IRegularUser>(nullDbContext), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains("An instance of DbContext is required to use this repository.")); }
public GenericRepository(IProgrammersSpotDbContext context) { if (context == null) { throw new ArgumentNullException("An instance of DbContext is required to use this repository.", "context"); } this.context = context; this.dbSet = this.context.Set <T>(); }
public CityRepository(IProgrammersSpotDbContext dbContext) : base(dbContext) { }
public UnitOfWork(IProgrammersSpotDbContext context) { Guard.WhenArgument(context, "Db context").IsNull().Throw(); this.context = context; }