コード例 #1
0
        public void ThrowArgumentNullException_WhenThePassedContextIsNull()
        {
            // Arrange
            ICarsSystemDbContext context = null;

            // Act & Assert
            Assert.Throws <ArgumentException>(() => new EfGenericRepository <Car>(context));
        }
        public EfGenericRepository(ICarsSystemDbContext context)
        {
            if (context == null)
            {
                throw new ArgumentException("An instance of DbContext is required to use this repository.", "context");
            }

            this.Context = context;
            this.DbSet   = this.Context.Set <T>();
        }
        public void EfGenericRepository_ShouldThrowArgumentNullException_WhenThePassedContextIsNull()
        {
            ICarsSystemDbContext context = null;

            Assert.Throws <ArgumentException>(() => new EfGenericRepository <Car>(context));
        }