public void TryTranslatePropertyCatchAllSegmentTemplate_ThrowsArgumentNull_Context()
        {
            // Arrange
            PropertyCatchAllSegmentTemplate pathSegment = new PropertyCatchAllSegmentTemplate(_entityType);

            // Act & Assert
            ExceptionAssert.ThrowsArgumentNull(() => pathSegment.TryTranslate(null), "context");
        }
        public void CtorPropertyCatchAllSegmentTemplate_SetsProperties()
        {
            // Arrange & Act
            PropertyCatchAllSegmentTemplate pathSegment = new PropertyCatchAllSegmentTemplate(_entityType);

            // Assert
            Assert.Same(_entityType, pathSegment.StructuredType);
        }
        public void GetTemplatesPropertyCatchAllSegmentTemplate_ReturnsTemplates()
        {
            // Arrange
            PropertyCatchAllSegmentTemplate pathSegment = new PropertyCatchAllSegmentTemplate(_entityType);

            // Act & Assert
            IEnumerable <string> templates = pathSegment.GetTemplates();
            string template = Assert.Single(templates);

            Assert.Equal("/{property}", template);
        }
        public void TryTranslatePropertyCatchAllSegmentTemplate_ReturnsFalse_NoCorrectRouteData()
        {
            // Arrange
            PropertyCatchAllSegmentTemplate pathSegment = new PropertyCatchAllSegmentTemplate(_entityType);
            ODataTemplateTranslateContext   context     = new ODataTemplateTranslateContext
            {
                RouteValues = new RouteValueDictionary()
            };

            // Act & Assert
            Assert.False(pathSegment.TryTranslate(context));
        }
        public void TryTranslatePropertyCatchAllSegmentTemplate_ReturnsPropertySegment(string property)
        {
            // Arrange
            RouteValueDictionary          routeValueDictionary = new RouteValueDictionary(new { property = $"{property}" });
            ODataTemplateTranslateContext context = new ODataTemplateTranslateContext
            {
                RouteValues = routeValueDictionary
            };

            PropertyCatchAllSegmentTemplate pathSegment = new PropertyCatchAllSegmentTemplate(_entityType);

            // Act
            bool ok = pathSegment.TryTranslate(context);

            // Assert
            Assert.True(ok);
            ODataPathSegment segment         = Assert.Single(context.Segments);
            PropertySegment  propertySegment = Assert.IsType <PropertySegment>(segment);

            Assert.Equal("Title", propertySegment.Property.Name);
        }