public void TryMatch_ReturnTrue_IfSameFunction()
        {
            // Arrange
            IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
            EdmFunction function = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));

            Dictionary<string, string> parameterValues = new Dictionary<string, string>()
            {
                { "Parameter1", "1" },
                { "Parameter2", "2" }
            };

            Dictionary<string, string> parameterMappings = new Dictionary<string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            BoundFunctionPathSegment segment = new BoundFunctionPathSegment(function, model: null, parameterValues: parameterValues);
            BoundFunctionPathSegmentTemplate template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model: null, parameterValues: parameterMappings));

            // Act
            Dictionary<string, object> values = new Dictionary<string,object>();
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.True(result);
            Assert.Equal(2, values.Count);
            Assert.Equal("1", values["param1"]);
            Assert.Equal("2", values["param2"]);
        }
Exemplo n.º 2
0
        public void TryMatch_ReturnTrue_IfSameFunction()
        {
            // Arrange
            IEdmEntityType returnType = new Mock <IEdmEntityType>().Object;
            EdmFunction    function   = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));

            Dictionary <string, string> parameterValues = new Dictionary <string, string>()
            {
                { "Parameter1", "1" },
                { "Parameter2", "2" }
            };

            Dictionary <string, string> parameterMappings = new Dictionary <string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            BoundFunctionPathSegment         segment  = new BoundFunctionPathSegment(function, model: null, parameterValues: parameterValues);
            BoundFunctionPathSegmentTemplate template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model: null, parameterValues: parameterMappings));

            // Act
            Dictionary <string, object> values = new Dictionary <string, object>();
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.True(result);
            Assert.Equal(2, values.Count);
            Assert.Equal("1", values["param1"]);
            Assert.Equal("2", values["param2"]);
        }
        public void Ctor_InitializeParameterMappingsProperty_Function()
        {
            // Arrange
            IEdmModel model = new Mock<IEdmModel>().Object;
            IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            EdmFunction function = new EdmFunction("NS", "Function",
                    new EdmEntityTypeReference(returnType, isNullable: false));

            Dictionary<string, string> parameterMappings = new Dictionary<string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            // Act
            var template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model, parameterMappings));

            // Assert
            Assert.Equal(2, template.ParameterMappings.Count);
        }
Exemplo n.º 4
0
        public void TryMatch_ReturnTrue_IfSameFunction()
        {
            // Arrange
            IEdmModel      model      = new Mock <IEdmModel>().Object;
            IEdmEntityType returnType = new Mock <IEdmEntityType>().Object;
            EdmFunction    function   = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));

            function.AddParameter("Parameter1", EdmCoreModel.Instance.GetInt32(isNullable: false));
            function.AddParameter("Parameter2", EdmCoreModel.Instance.GetInt32(isNullable: false));

            Dictionary <string, string> parameterValues = new Dictionary <string, string>()
            {
                { "Parameter1", "1" },
                { "Parameter2", "2" }
            };

            Dictionary <string, string> parameterMappings = new Dictionary <string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            BoundFunctionPathSegment         segment  = new BoundFunctionPathSegment(function, model, parameterValues: parameterValues);
            BoundFunctionPathSegmentTemplate template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model, parameterValues: parameterMappings));

            // Act
            Dictionary <string, object> values = new Dictionary <string, object>();
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.True(result);
            Assert.Equal(4, values.Count);
            Assert.Equal("1", values["param1"]);
            Assert.Equal("2", values["param2"]);

            Assert.Equal(1, (values[ODataParameterValue.ParameterValuePrefix + "param1"] as ODataParameterValue).Value);
            Assert.Equal(2, (values[ODataParameterValue.ParameterValuePrefix + "param2"] as ODataParameterValue).Value);
        }
Exemplo n.º 5
0
        public void Ctor_InitializeParameterMappingsProperty_Function()
        {
            // Arrange
            IEdmModel          model      = new Mock <IEdmModel>().Object;
            IEdmEntityType     returnType = new Mock <IEdmEntityType>().Object;
            EdmEntityContainer container  = new EdmEntityContainer("NS", "Container");
            EdmFunction        function   = new EdmFunction("NS", "Function",
                                                            new EdmEntityTypeReference(returnType, isNullable: false));

            Dictionary <string, string> parameterMappings = new Dictionary <string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            // Act
            var template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model, parameterMappings));

            // Assert
            Assert.Equal(2, template.ParameterMappings.Count);
        }
        public void TryMatch_ReturnTrue_IfSameFunction()
        {
            // Arrange
            IEdmModel model = new Mock<IEdmModel>().Object;
            IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
            EdmFunction function = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));
            function.AddParameter("Parameter1", EdmCoreModel.Instance.GetInt32(isNullable: false));
            function.AddParameter("Parameter2", EdmCoreModel.Instance.GetInt32(isNullable: false));

            Dictionary<string, string> parameterValues = new Dictionary<string, string>()
            {
                { "Parameter1", "1" },
                { "Parameter2", "2" }
            };

            Dictionary<string, string> parameterMappings = new Dictionary<string, string>()
            {
                { "Parameter1", "{param1}" },
                { "Parameter2", "{param2}" }
            };

            BoundFunctionPathSegment segment = new BoundFunctionPathSegment(function, model, parameterValues: parameterValues);
            BoundFunctionPathSegmentTemplate template = new BoundFunctionPathSegmentTemplate(
                new BoundFunctionPathSegment(function, model, parameterValues: parameterMappings));

            // Act
            Dictionary<string, object> values = new Dictionary<string,object>();
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.True(result);
            Assert.Equal(4, values.Count);
            Assert.Equal("1", values["param1"]);
            Assert.Equal("2", values["param2"]);

            Assert.Equal(1, (values[ODataParameterValue.ParameterValuePrefix + "param1"] as ODataParameterValue).Value);
            Assert.Equal(2, (values[ODataParameterValue.ParameterValuePrefix + "param2"] as ODataParameterValue).Value);
        }