예제 #1
0
        public void TryMatch_ReturnsFalse_IfDifferentUnboundFunctionWithSameParamerters()
        {
            // 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));
            EdmFunctionImport  functionImport1 = new EdmFunctionImport(container, "FunctionImport1", function);
            EdmFunctionImport  functionImport2 = new EdmFunctionImport(container, "FunctionImport2", function);

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

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

            UnboundFunctionPathSegment segment = new UnboundFunctionPathSegment(functionImport1, model, parameterValues);
            var template = new UnboundFunctionPathSegmentTemplate(
                new UnboundFunctionPathSegment(functionImport2, model, parameterMappings));
            Dictionary <string, object> values = new Dictionary <string, object>();

            // Act
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.False(result);
        }
예제 #2
0
        public void TryMatch_ReturnTrue_IfSameUnboundFunction()
        {
            // Arrange
            IEdmModel          model      = new Mock <IEdmModel>().Object;
            IEdmEntityType     returnType = new Mock <IEdmEntityType>().Object;
            EdmEntityContainer container  = new EdmEntityContainer("NS", "Container");

            EdmFunction func = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));

            func.AddParameter("Parameter1", EdmCoreModel.Instance.GetInt32(isNullable: false));
            func.AddParameter("Parameter2", EdmCoreModel.Instance.GetInt32(isNullable: false));
            EdmFunctionImport function = new EdmFunctionImport(container, "Function", func);

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

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

            UnboundFunctionPathSegment         segment  = new UnboundFunctionPathSegment(function, model, parameterValues);
            UnboundFunctionPathSegmentTemplate template = new UnboundFunctionPathSegmentTemplate(
                new UnboundFunctionPathSegment(function, model, 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);
        }
        public void TryMatch_ReturnTrue_IfSameUnboundFunction()
        {
            // Arrange
            IEdmModel model = new Mock<IEdmModel>().Object;
            IEdmEntityType returnType = new Mock<IEdmEntityType>().Object;
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");

            EdmFunction func = new EdmFunction("NS", "Function", new EdmEntityTypeReference(returnType, isNullable: false));
            func.AddParameter("Parameter1", EdmCoreModel.Instance.GetInt32(isNullable: false));
            func.AddParameter("Parameter2", EdmCoreModel.Instance.GetInt32(isNullable: false));
            EdmFunctionImport function = new EdmFunctionImport(container, "Function", func);

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

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

            UnboundFunctionPathSegment segment = new UnboundFunctionPathSegment(function, model, parameterValues);
            UnboundFunctionPathSegmentTemplate template = new UnboundFunctionPathSegmentTemplate(
                new UnboundFunctionPathSegment(function, model, 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);
        }
        public void TryMatch_ReturnsFalse_IfDifferentUnboundFunctionWithSameParamerters()
        {
            // 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));
            EdmFunctionImport functionImport1 = new EdmFunctionImport(container,"FunctionImport1", function);
            EdmFunctionImport functionImport2 = new EdmFunctionImport(container,"FunctionImport2", function);

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

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

            UnboundFunctionPathSegment segment = new UnboundFunctionPathSegment(functionImport1, model, parameterValues);
            var template = new UnboundFunctionPathSegmentTemplate(
                new UnboundFunctionPathSegment(functionImport2, model, parameterMappings));
            Dictionary<string, object> values = new Dictionary<string, object>();

            // Act
            bool result = template.TryMatch(segment, values);

            // Assert
            Assert.False(result);
        }