public void Property_SegmentKind_IsUnboundAction()
        {
            // Arrange
            UnboundActionPathSegment segment = new UnboundActionPathSegment("SomeAction");

            // Act & Assert
            Assert.Equal(ODataSegmentKinds.UnboundAction, segment.SegmentKind);
        }
Exemple #2
0
        public void Property_SegmentKind_IsUnboundAction()
        {
            // Arrange
            UnboundActionPathSegment segment = new UnboundActionPathSegment("SomeAction");

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

            // Act & Assert
            Assert.Null(actionPathSegment.Action);
            Assert.Equal("SomeAction", actionPathSegment.ActionName);
        }
Exemple #4
0
        public void GetEdmType_ThrowArgumentException_IfArgumentNotNull()
        {
            // Arrange
            var             segment = new UnboundActionPathSegment("CreateCustomer");
            Mock <IEdmType> edmType = new Mock <IEdmType>();

            // Act & Assert
            Assert.Throws <ArgumentException>(() => segment.GetEdmType(edmType.Object));
        }
Exemple #5
0
        public void Ctor_TakingActionName_InitializesActionNameProperty()
        {
            // Arrange
            UnboundActionPathSegment actionPathSegment = new UnboundActionPathSegment("SomeAction");

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

            return(false);
        }
        public void Ctor_TakingAction_InitializesActionNameProperty()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment actionPathSegment = new UnboundActionPathSegment(action);

            // Assert
            Assert.Equal("CreateCustomer", actionPathSegment.ActionName);
        }
Exemple #8
0
        public void Ctor_TakingAction_InitializesActionNameProperty()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment actionPathSegment = new UnboundActionPathSegment(action);

            // Assert
            Assert.Equal("CreateCustomer", actionPathSegment.ActionName);
        }
        public void GetEdmType_ReturnsNull_IfActionNull()
        {
            // Arrange
            var segment = new UnboundActionPathSegment("TopCustomer");

            // Act
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.Null(result);
        }
Exemple #10
0
        public void ToString_ReturnsActionName()
        {
            // Arrange
            IEdmActionImport         action  = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);

            // Act
            var result = segment.ToString();

            // Assert
            Assert.Equal("CreateCustomer", result);
        }
Exemple #11
0
        public void GetNavigationSource_ReturnsNull_UnboundActionPrimitveReturnType()
        {
            // Arrange
            IEdmActionImport         action  = _container.FindOperationImports("MyAction").SingleOrDefault() as IEdmActionImport;
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);

            // Act
            var result = segment.GetNavigationSource(previousNavigationSource: null);

            // Assert
            Assert.Null(result);
        }
Exemple #12
0
        public void GetEdmType_ReturnsNull_UnboundAction()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("ActionWithoutReturn").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.Null(result);
        }
        public void Ctor_TakingAction_InitializesActionProperty()
        {
            // Arrange
            Mock<IEdmActionImport> edmAction = new Mock<IEdmActionImport>();
            edmAction.Setup(a => a.Name).Returns("SomeAction");

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

            // Assert
            Assert.Same(edmAction.Object, actionPathSegment.Action);
        }
Exemple #14
0
        public void GetEdmType_ReturnsNotNull_UnboundActionEntityType()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("System.Web.OData.Routing.MyCustomer", result.FullTypeName());
        }
Exemple #15
0
        public void Ctor_TakingAction_InitializesActionProperty()
        {
            // Arrange
            Mock <IEdmActionImport> edmAction = new Mock <IEdmActionImport>();

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

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

            // Assert
            Assert.Same(edmAction.Object, actionPathSegment.Action);
        }
Exemple #16
0
        public void GetEdmType_ReturnsNotNull_UnboundActionPrimitiveType()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("MyAction").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("Edm.String", result.FullTypeName());
        }
Exemple #17
0
        public void Translate_OperationImportSegment_To_UnboundActionPathSegment_Works()
        {
            // Arrange
            IEdmEntitySet entityset = _model.FindDeclaredEntitySet("SalesPeople");
            IEnumerable <IEdmOperationImport> operationImports = _model.FindDeclaredOperationImports("GetSalesPersonById");
            OperationImportSegment            segment          = new OperationImportSegment(operationImports, entityset);

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

            // Assert
            ODataPathSegment         pathSegment = Assert.Single(segments);
            UnboundActionPathSegment unboundActionPathSegment = Assert.IsType <UnboundActionPathSegment>(pathSegment);

            Assert.Same(operationImports.First(), unboundActionPathSegment.Action);
        }
Exemple #18
0
        public void TryMatch_ReturnsTrue_IfThePathSegmentRefersToSameAction()
        {
            // Arrange
            EdmEntityContainer      container = new EdmEntityContainer("NS", "Container");
            Mock <IEdmActionImport> edmAction = new Mock <IEdmActionImport>();

            edmAction.Setup(a => a.Name).Returns("SomeAction");
            edmAction.Setup(a => a.Container).Returns(container);

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

            // Act
            var match = pathSegmentTemplate.TryMatch(pathSegment, values);

            // Assert
            Assert.True(match);
            Assert.Empty(values);
        }
        public void GetEdmType_ReturnsNull_IfActionNull()
        {
            // Arrange
            var segment = new UnboundActionPathSegment("TopCustomer");

            // Act
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.Null(result);
        }
        public void GetEdmType_ReturnsNotNull_UnboundActionEntityType()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("System.Web.OData.Routing.MyCustomer", result.FullTypeName());
        }
        public void GetEdmType_ThrowArgumentException_IfArgumentNotNull()
        {
            // Arrange
            var segment = new UnboundActionPathSegment("CreateCustomer");
            Mock<IEdmType> edmType = new Mock<IEdmType>();

            // Act & Assert
            Assert.Throws<ArgumentException>(() => segment.GetEdmType(edmType.Object));
        }
        public void GetEdmType_ReturnsNotNull_UnboundActionPrimitiveType()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("MyAction").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("Edm.String", result.FullTypeName());
        }
        public void GetEdmType_ReturnsNull_UnboundAction()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("ActionWithoutReturn").SingleOrDefault() as IEdmActionImport;

            // Act
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);
            var result = segment.GetEdmType(previousEdmType: null);

            // Assert
            Assert.Null(result);
        }
        public void GetEntitySet_ReturnsNull_UnboundActionPrimitveReturnType()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("MyAction").SingleOrDefault() as IEdmActionImport;
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);

            // Act
            var result = segment.GetEntitySet(previousEntitySet: null);

            // Assert
            Assert.Null(result);
        }
        public void TryMatch_ReturnsTrue_IfThePathSegmentRefersToSameAction()
        {
            // Arrange
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            Mock<IEdmActionImport> edmAction = new Mock<IEdmActionImport>();
            edmAction.Setup(a => a.Name).Returns("SomeAction");
            edmAction.Setup(a => a.Container).Returns(container);

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

            // Act
            var match = pathSegmentTemplate.TryMatch(pathSegment, values);

            // Assert
            Assert.True(match);
            Assert.Empty(values);
        }
        public void ToString_ReturnsActionName()
        {
            // Arrange
            IEdmActionImport action = _container.FindOperationImports("CreateCustomer").SingleOrDefault() as IEdmActionImport;
            UnboundActionPathSegment segment = new UnboundActionPathSegment(action);

            // Act
            var result = segment.ToString();

            // Assert
            Assert.Equal("CreateCustomer", result);
        }