Пример #1
0
        public void GetEntityCount_WithUnTypedContext_Throws_InvalidOperation()
        {
            // Arrange
            CustomersModelWithInheritance model       = new CustomersModelWithInheritance();
            ODataQueryContext             context     = new ODataQueryContext(model.Model, model.Customer);
            InlineCountQueryOption        inlineCount = new InlineCountQueryOption("allpages", context);
            IQueryable queryable = new Mock <IQueryable>().Object;

            // Act & Assert
            Assert.Throws <NotSupportedException>(() => inlineCount.GetEntityCount(queryable),
                                                  "The query option is not bound to any CLR type. 'GetEntityCount' is only supported with a query option bound to a CLR type.");
        }
Пример #2
0
        public void GetEntityCount_ReturnsNull_IfValueIsNone()
        {
            var inlineCount = new InlineCountQueryOption("none", _context);

            Assert.Null(inlineCount.GetEntityCount(_customers));
        }
Пример #3
0
        public void GetEntityCount_ReturnsCount_IfValueIsAllPages()
        {
            var inlineCount = new InlineCountQueryOption("allpages", _context);

            Assert.Equal(3, inlineCount.GetEntityCount(_customers));
        }
        public void GetEntityCount_WithUnTypedContext_Throws_InvalidOperation()
        {
            // Arrange
            CustomersModelWithInheritance model = new CustomersModelWithInheritance();
            ODataQueryContext context = new ODataQueryContext(model.Model, model.Customer);
            InlineCountQueryOption inlineCount = new InlineCountQueryOption("allpages", context);
            IQueryable queryable = new Mock<IQueryable>().Object;

            // Act & Assert
            Assert.Throws<NotSupportedException>(() => inlineCount.GetEntityCount(queryable),
                "The query option is not bound to any CLR type. 'GetEntityCount' is only supported with a query option bound to a CLR type.");
        }
        public void GetEntityCount_ReturnsNull_IfValueIsNone()
        {
            var inlineCount = new InlineCountQueryOption("none", _context);

            Assert.Null(inlineCount.GetEntityCount(_customers));
        }
        public void GetEntityCount_ReturnsCount_IfValueIsAllPages()
        {
            var inlineCount = new InlineCountQueryOption("allpages", _context);

            Assert.Equal(3, inlineCount.GetEntityCount(_customers));
        }