Exemplo n.º 1
0
        internal static void SetSource <T>(this AsyncQueryProvider <T> mockedQueryProvider, IEnumerable <T> source) where T : class
        {
            EnsureArgument.IsNotNull(mockedQueryProvider, nameof(mockedQueryProvider));
            EnsureArgument.IsNotNull(source, nameof(source));

            mockedQueryProvider.Source = source.AsQueryable();
        }
        internal static void SetSource <T>(this AsyncQueryProvider <T> mockedQueryProvider, IEnumerable <T> source) where T : class
        {
            EnsureArgument.IsNotNull(mockedQueryProvider, nameof(mockedQueryProvider));
            EnsureArgument.IsNotNull(source, nameof(source));

            var queryable = source.AsQueryable();

            mockedQueryProvider.Configure().Source.Returns(callInfo => queryable);
        }
        internal static void SetSource <T>(this AsyncQueryProvider <T> mockedQueryProvider, IEnumerable <T> source) where T : class
        {
            EnsureArgument.IsNotNull(mockedQueryProvider, nameof(mockedQueryProvider));
            EnsureArgument.IsNotNull(source, nameof(source));

            var queryProviderMock = Mock.Get(mockedQueryProvider);

            var queryable = source.AsQueryable();

            queryProviderMock.Setup(m => m.Source).Returns(() => queryable);
        }
Exemplo n.º 4
0
        public void ExecuteMustReturnResultOfExpressionWhenCalled()
        {
            AsyncQueryProvider <int> provider = new AsyncQueryProvider <int>(new EnumerableQuery <int>(Expression.Empty()));

            Assert.Equal(42, provider.Execute(Expression.Constant(42)));
        }