Beispiel #1
0
        public void Non_entity_SQL_query_GetList_throws_indicating_that_binding_to_queries_is_not_allowed()
        {
            var query = new DbRawSqlQuery <Random>(MockHelper.CreateInternalSqlNonSetQuery("query"));

            Assert.Equal(
                Strings.DbQuery_BindingToDbQueryNotSupported,
                Assert.Throws <NotSupportedException>(() => ((IListSource)query).GetList()).Message);
        }
Beispiel #2
0
        public void Generic_non_entity_SQL_query_ToString_returns_the_query_but_not_the_parameters()
        {
            var query =
                new DbRawSqlQuery <FakeEntity>(
                    MockHelper.CreateInternalSqlNonSetQuery("select * from Products where Id < {0} and CategoryId = '{1}'", 4, "Beverages"));

            Assert.Equal("select * from Products where Id < {0} and CategoryId = '{1}'", query.ToString());
        }
Beispiel #3
0
            public void MaxAsync_throws_OperationCanceledException_if_task_is_cancelled()
            {
                var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("select * from products"));

                Assert.Throws <OperationCanceledException>(
                    () => query.MaxAsync(new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());
            }
Beispiel #4
0
            public void ToDictionaryAsync_throws_OperationCanceledException_if_task_is_cancelled()
            {
                var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("select * from products"));

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, n => n, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                var equalityComparer = new Mock <IEqualityComparer <FakeEntity> >().Object;

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, equalityComparer, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());

                Assert.Throws <OperationCanceledException>(
                    () => query.ToDictionaryAsync(n => n, n => n, equalityComparer, new CancellationToken(canceled: true))
                    .GetAwaiter().GetResult());
            }
Beispiel #5
0
        public void Non_entity_SQL_query_ContainsListCollection_returns_false()
        {
            var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("query"));

            Assert.False(((IListSource)query).ContainsListCollection);
        }
Beispiel #6
0
        public void Generic_non_entity_SQL_query_ToString_returns_the_query()
        {
            var query = new DbRawSqlQuery <FakeEntity>(MockHelper.CreateInternalSqlNonSetQuery("select * from products"));

            Assert.Equal("select * from products", query.ToString());
        }