public void Property_SegmentKind_IsBoundAction()
        {
            // Arrange
            BoundActionPathSegment segment = new BoundActionPathSegment("SomeAction");

            // Act & Assert
            Assert.Equal(ODataSegmentKinds.Action, segment.SegmentKind);
        }
Esempio n. 2
0
        public void Property_SegmentKind_IsBoundAction()
        {
            // Arrange
            BoundActionPathSegment segment = new BoundActionPathSegment("SomeAction");

            // Act & Assert
            Assert.Equal(ODataSegmentKinds.Action, segment.SegmentKind);
        }
        public void Ctor_TakingActionName_InitializesActionNameProperty()
        {
            // Arrange
            BoundActionPathSegment actionPathSegment = new BoundActionPathSegment("SomeAction");

            // Act & Assert
            Assert.Null(actionPathSegment.Action);
            Assert.Equal("SomeAction", actionPathSegment.ActionName);
        }
Esempio n. 4
0
        public void Ctor_TakingActionName_InitializesActionNameProperty()
        {
            // Arrange
            BoundActionPathSegment actionPathSegment = new BoundActionPathSegment("SomeAction");

            // Act & Assert
            Assert.Null(actionPathSegment.Action);
            Assert.Equal("SomeAction", actionPathSegment.ActionName);
        }
Esempio n. 5
0
        /// <inheritdoc/>
        public override bool TryMatch(ODataPathSegment pathSegment, IDictionary <string, object> values)
        {
            if (pathSegment.SegmentKind == ODataSegmentKinds.Action)
            {
                BoundActionPathSegment actionSegment = (BoundActionPathSegment)pathSegment;
                return(actionSegment.Action == Action && actionSegment.ActionName == ActionName);
            }

            return(false);
        }
        public void Ctor_TakingAction_InitializesActionNameProperty()
        {
            // Arrange
            Mock<IEdmAction> edmAction = new Mock<IEdmAction>();
            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            // Act
            BoundActionPathSegment actionPathSegment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Equal("NS.SomeAction", actionPathSegment.ActionName);
        }
        public void GetNavigationSource_Returns_ActionTargetEntitySet_EntitySetPathExpression()
        {
            // Arrange
            IEdmModel     model              = GetEdmModel();
            IEdmAction    action             = model.SchemaElements.OfType <IEdmAction>().First(c => c.Name == "GetMyOrders1");
            IEdmEntitySet previouseEntitySet = model.EntityContainer.FindEntitySet("MyCustomers");
            IEdmEntitySet expectedEntitySet  = model.EntityContainer.FindEntitySet("MyOrders");

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(action, model);

            // Assert
            Assert.Same(expectedEntitySet, segment.GetNavigationSource(previouseEntitySet));
        }
Esempio n. 8
0
        public void Ctor_TakingAction_InitializesActionNameProperty()
        {
            // Arrange
            Mock <IEdmAction> edmAction = new Mock <IEdmAction>();

            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            // Act
            BoundActionPathSegment actionPathSegment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Equal("NS.SomeAction", actionPathSegment.ActionName);
        }
        public void GetEdmType_Returns_ActionReturnType()
        {
            // Arrange
            Mock<IEdmEntityType> returnType = new Mock<IEdmEntityType>();
            Mock<IEdmAction> edmAction = new Mock<IEdmAction>();
            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");
            edmAction.Setup(a => a.ReturnType).Returns(new EdmEntityTypeReference(returnType.Object, isNullable: false));

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Same(returnType.Object, segment.GetEdmType(previousEdmType: null));
        }
Esempio n. 10
0
        public void GetNavigationSource_Returns_ActionTargetEntitySet()
        {
            // Arrange
            Mock <IEdmEntitySet> targetEntitySet = new Mock <IEdmEntitySet>();
            Mock <IEdmAction>    edmAction       = new Mock <IEdmAction>();

            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Same(targetEntitySet.Object, segment.GetNavigationSource(targetEntitySet.Object));
        }
Esempio n. 11
0
        public void Translate_OperationSegment_To_BoundActionPathSegment_Works()
        {
            // Arrange
            IEdmEntitySet entityset = _model.FindDeclaredEntitySet("Products");
            IEnumerable <IEdmOperation> operations = _model.FindDeclaredOperations("Default.GetProducts");
            OperationSegment            segment    = new OperationSegment(operations, entityset);

            // Act
            IEnumerable <ODataPathSegment> segments = _translator.Translate(segment);

            // Assert
            ODataPathSegment       pathSegment            = Assert.Single(segments);
            BoundActionPathSegment boundActionPathSegment = Assert.IsType <BoundActionPathSegment>(pathSegment);

            Assert.Same(operations.First(), boundActionPathSegment.Action);
        }
Esempio n. 12
0
        public void GetEdmType_Returns_ActionReturnType()
        {
            // Arrange
            Mock <IEdmEntityType> returnType = new Mock <IEdmEntityType>();
            Mock <IEdmAction>     edmAction  = new Mock <IEdmAction>();

            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");
            edmAction.Setup(a => a.ReturnType).Returns(new EdmEntityTypeReference(returnType.Object, isNullable: false));

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Same(returnType.Object, segment.GetEdmType(previousEdmType: null));
        }
Esempio n. 13
0
        public void TryMatch_ReturnsTrue_IfThePathSegmentRefersToSameAction()
        {
            // Arrange
            Mock <IEdmAction> edmAction = new Mock <IEdmAction>();

            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            BoundActionPathSegment      pathSegmentTemplate = new BoundActionPathSegment(edmAction.Object);
            BoundActionPathSegment      pathSegment         = new BoundActionPathSegment(edmAction.Object);
            Dictionary <string, object> values = new Dictionary <string, object>();

            // Act & Assert
            Assert.True(pathSegmentTemplate.TryMatch(pathSegment, values));
            Assert.Empty(values);
        }
        public void GetNavigationSource_Returns_ActionTargetEntitySet()
        {
            // Arrange
            Mock<IEdmEntitySet> targetEntitySet = new Mock<IEdmEntitySet>();
            Mock<IEdmAction> edmAction = new Mock<IEdmAction>();
            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(edmAction.Object);

            // Assert
            Assert.Same(targetEntitySet.Object, segment.GetNavigationSource(targetEntitySet.Object));
        }
        public void GetNavigationSource_Returns_ActionTargetEntitySet_EntitySetPathExpression()
        {
            // Arrange
            IEdmModel model = GetEdmModel();
            IEdmAction action = model.SchemaElements.OfType<IEdmAction>().First(c => c.Name == "GetMyOrders1");
            IEdmEntitySet previouseEntitySet = model.EntityContainer.FindEntitySet("MyCustomers");
            IEdmEntitySet expectedEntitySet = model.EntityContainer.FindEntitySet("MyOrders");

            // Act
            BoundActionPathSegment segment = new BoundActionPathSegment(action, model);

            // Assert
            Assert.Same(expectedEntitySet, segment.GetNavigationSource(previouseEntitySet));
        }
 public void ToString_ReturnsActionName()
 {
     BoundActionPathSegment segment = new BoundActionPathSegment(actionName: "SomeAction");
     Assert.Equal("SomeAction", segment.ToString());
 }
        public void TryMatch_ReturnsTrue_IfThePathSegmentRefersToSameAction()
        {
            // Arrange
            Mock<IEdmAction> edmAction = new Mock<IEdmAction>();
            edmAction.Setup(a => a.Namespace).Returns("NS");
            edmAction.Setup(a => a.Name).Returns("SomeAction");

            BoundActionPathSegment pathSegmentTemplate = new BoundActionPathSegment(edmAction.Object);
            BoundActionPathSegment pathSegment = new BoundActionPathSegment(edmAction.Object);
            Dictionary<string, object> values = new Dictionary<string, object>();

            // Act & Assert
            Assert.True(pathSegmentTemplate.TryMatch(pathSegment, values));
            Assert.Empty(values);
        }
Esempio n. 18
0
        public void ToString_ReturnsActionName()
        {
            BoundActionPathSegment segment = new BoundActionPathSegment(actionName: "SomeAction");

            Assert.Equal("SomeAction", segment.ToString());
        }