예제 #1
0
 public void Init()
 {
     baseUri           = new Uri("http://base.org/");
     context           = new DataServiceContext(baseUri);
     personQueryable   = this.CreateSingletonQuery <Person>("Vip");
     customerQueryable = this.CreateSingletonQuery <Customer>("Vip");
 }
예제 #2
0
        public void Initialize_WithProvider()
        {
            QueryableBase <int> queryable = new TestQueryable <int> (_providerMock);

            Assert.That(queryable.Provider, Is.SameAs(_providerMock));
            Assert.That(queryable.Expression, Is.Not.Null);
            Assert.That(queryable.Expression.NodeType, Is.EqualTo(ExpressionType.Constant));
        }
예제 #3
0
    public void Initialize_WithProvider ()
    {
      QueryableBase<int> queryable = new TestQueryable<int> (_providerMock);

      Assert.That (queryable.Provider, Is.SameAs (_providerMock));
      Assert.That (queryable.Expression, Is.Not.Null);
      Assert.That (queryable.Expression.NodeType, Is.EqualTo (ExpressionType.Constant));
    }
예제 #4
0
        public void Initialize_WithProviderAndExpression()
        {
            QueryableBase <int> queryable = new TestQueryable <int> (_providerMock, _intArrayExpression);

            Assert.That(queryable.Provider, Is.SameAs(_providerMock));
            Assert.That(queryable.Expression, Is.SameAs(_intArrayExpression));

            Assert.That(queryable.ElementType, Is.EqualTo(typeof(int)));
        }
예제 #5
0
    public void Initialize_WithProviderAndExpression ()
    {
      QueryableBase<int> queryable = new TestQueryable<int> (_providerMock, _intArrayExpression);

      Assert.That (queryable.Provider, Is.SameAs (_providerMock));
      Assert.That (queryable.Expression, Is.SameAs (_intArrayExpression));

      Assert.That (queryable.ElementType, Is.EqualTo (typeof (int)));
    }
예제 #6
0
        public void GenericGetEnumerator()
        {
            _providerMock.Expect(mock => mock.Execute <IEnumerable <int> > (_intArrayExpression)).Return(new List <int>(0));

            _providerMock.Replay();
            QueryableBase <int> queryable = new TestQueryable <int> (_providerMock, _intArrayExpression);

            queryable.GetEnumerator();
            _providerMock.VerifyAllExpectations();
        }
예제 #7
0
        public void SetUp()
        {
            _mockRepository  = new MockRepository();
            _queryParserMock = _mockRepository.StrictMock <IQueryParser> ();
            _executorMock    = _mockRepository.StrictMock <IQueryExecutor> ();

            _queryProvider = new TestQueryProvider(_queryParserMock, _executorMock);

            _queryableWithDefaultParser = new TestQueryable <Cook> (QueryParser.CreateDefault(), _executorMock);
            _fakeQueryModel             = ExpressionHelper.CreateQueryModel <Cook> ();
        }
예제 #8
0
    public void SetUp()
    {
      _mockRepository = new MockRepository();
      _queryParserMock = _mockRepository.StrictMock<IQueryParser> ();
      _executorMock = _mockRepository.StrictMock<IQueryExecutor> ();

      _queryProvider = new TestQueryProvider (_queryParserMock, _executorMock);
    
      _queryableWithDefaultParser = new TestQueryable<Cook> (QueryParser.CreateDefault(), _executorMock);
      _fakeQueryModel = ExpressionHelper.CreateQueryModel<Cook> ();
    }
예제 #9
0
    public void Initialize_WithParserAndExecutor ()
    {
      var fakeExecutor = _mockRepository.Stub<IQueryExecutor>();
      var fakeParser = _mockRepository.Stub<IQueryParser> ();
      QueryableBase<int> queryable = new TestQueryable<int> (fakeParser, fakeExecutor);

      Assert.That (queryable.Expression, Is.Not.Null);
      Assert.That (queryable.Expression.NodeType, Is.EqualTo (ExpressionType.Constant));
      Assert.That (queryable.Provider, Is.InstanceOf (typeof (DefaultQueryProvider)));

      var queryProvider = ((DefaultQueryProvider) queryable.Provider);
      Assert.That (queryProvider.Executor, Is.SameAs (fakeExecutor));
      Assert.That (queryProvider.QueryableType, Is.SameAs (typeof (TestQueryable<>)));
      Assert.That (queryProvider.QueryParser, Is.SameAs (fakeParser));
    }
예제 #10
0
        public void Initialize_WithParserAndExecutor()
        {
            var fakeExecutor = _mockRepository.Stub <IQueryExecutor>();
            var fakeParser   = _mockRepository.Stub <IQueryParser> ();
            QueryableBase <int> queryable = new TestQueryable <int> (fakeParser, fakeExecutor);

            Assert.That(queryable.Expression, Is.Not.Null);
            Assert.That(queryable.Expression.NodeType, Is.EqualTo(ExpressionType.Constant));
            Assert.That(queryable.Provider, Is.InstanceOf(typeof(DefaultQueryProvider)));

            var queryProvider = ((DefaultQueryProvider)queryable.Provider);

            Assert.That(queryProvider.Executor, Is.SameAs(fakeExecutor));
            Assert.That(queryProvider.QueryableType, Is.SameAs(typeof(TestQueryable <>)));
            Assert.That(queryProvider.QueryParser, Is.SameAs(fakeParser));
        }
예제 #11
0
 private Expression CreateExpression <TElement>(string methodName, TestQueryable <TElement> queryable)
 {
     return(Expression.Call(typeof(Queryable), methodName, new[] { queryable.ElementType }, queryable.Expression));
 }
예제 #12
0
    public void GenericGetEnumerator ()
    {
      _providerMock.Expect (mock => mock.Execute<IEnumerable<int>> (_intArrayExpression)).Return (new List<int>(0));

      _providerMock.Replay ();
      QueryableBase<int> queryable = new TestQueryable<int> (_providerMock, _intArrayExpression);
      queryable.GetEnumerator();
      _providerMock.VerifyAllExpectations();
    }