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>();
        }
Example #3
0
        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)));
        }
Example #6
0
        public UnitOfWork(ICarAdvertsSystemDbContext context)
        {
            Guard.WhenArgument(context, "Db context is null!").IsNull().Throw();

            this.context = context;
        }
Example #7
0
 public EfDeletableRepository(ICarAdvertsSystemDbContext context)
     : base(context)
 {
 }
Example #8
0
        public EfCarAdvertsDataProvider(ICarAdvertsSystemDbContext context)
        {
            Guard.WhenArgument(context, nameof(ICarAdvertsSystemDbContext)).IsNull().Throw();

            this.context = context;
        }