public GenericRepository(ICarAdvertsSystemDbContext context) { Guard.WhenArgument(context, "An instance of DbContext is required to use this repository.").IsNull().Throw(); this.Context = context; this.DbSet = this.Context.Set <T>(); }
public EfGenericRepository(ICarAdvertsSystemDbContext context) { Guard.WhenArgument(context, nameof(ICarAdvertsSystemDbContext)).IsNull().Throw(); this.Context = context; this.DbSet = this.Context.Set <T>(); }
public void ConstructorShould_ShouldThrowArgumentNullException_IfPassedContextIsNullWithAppropriateMessage() { ICarAdvertsSystemDbContext contextThatIsNull = null; Assert.That(() => new GenericRepository <IAdvert>(contextThatIsNull), Throws.ArgumentNullException.With.Message.Contains ("An instance of DbContext is required to use this repository.")); }
public void Contructor_Should_ThrowArgumentNullException_IfPassedDbContextIsNull() { ICarAdvertsSystemDbContext dbContextThatIsNull = null; Assert.That( () => new UnitOfWork(dbContextThatIsNull), Throws.InstanceOf <ArgumentNullException>().With.Message.Contains("Db context is null!")); }
public void ConstructorShould_ShouldThrowArgumentNullExceptionWithAppropriateMessage_IfPassedContextIsNull() { // Arrange ICarAdvertsSystemDbContext contextThatIsNull = null; // Act and Assert Assert.That(() => new EfCarAdvertsDataProvider(contextThatIsNull), Throws.ArgumentNullException.With.Message.Contains (nameof(ICarAdvertsSystemDbContext))); }
public UnitOfWork(ICarAdvertsSystemDbContext context) { Guard.WhenArgument(context, "Db context is null!").IsNull().Throw(); this.context = context; }
public EfDeletableRepository(ICarAdvertsSystemDbContext context) : base(context) { }
public EfCarAdvertsDataProvider(ICarAdvertsSystemDbContext context) { Guard.WhenArgument(context, nameof(ICarAdvertsSystemDbContext)).IsNull().Throw(); this.context = context; }