Ejemplo n.º 1
0
            public void CreateRequest_ShouldParseValidNamespace(string query, string expected)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters = HttpUtility.ParseQueryString(query);

                var request = processor.CreateRequest(parameters);

                if (expected != null)
                {
                    var prefixesNamespaces = expected.Split(';', ',');
                    Assert.True((prefixesNamespaces.Length % 2) == 0);

                    for (int i = 0; i < prefixesNamespaces.Length / 2; ++i)
                    {
                        var prefix     = prefixesNamespaces[2 * i];
                        var @namespace = prefixesNamespaces[2 * i + 1];
                        if (!string.IsNullOrEmpty(prefix))
                        {
                            Assert.Equal <string>(prefix, request.Untyped.GetPrefixOfNamespace(@namespace));
                            Assert.Equal <string>(@namespace, request.Untyped.GetNamespaceOfPrefix(prefix).NamespaceName);
                        }
                        else
                        {
                            Assert.Equal <string>(@namespace, request.Untyped.GetDefaultNamespace().NamespaceName);
                        }
                    }
                }
            }
Ejemplo n.º 2
0
            public void CreateRequest_ShouldParseValidNamespace(string query, string expected)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters=HttpUtility.ParseQueryString(query);

                var request=processor.CreateRequest(parameters);

                if (expected!=null)
                {
                    var prefixesNamespaces=expected.Split(';', ',');
                    Assert.True((prefixesNamespaces.Length % 2)==0);

                    for (int i=0; i<prefixesNamespaces.Length/2; ++i)
                    {
                        var prefix=prefixesNamespaces[2*i];
                        var @namespace=prefixesNamespaces[2*i+1];
                        if (!string.IsNullOrEmpty(prefix))
                        {
                            Assert.Equal<string>(prefix, request.Untyped.GetPrefixOfNamespace(@namespace));
                            Assert.Equal<string>(@namespace, request.Untyped.GetNamespaceOfPrefix(prefix).NamespaceName);
                        } else
                            Assert.Equal<string>(@namespace, request.Untyped.GetDefaultNamespace().NamespaceName);
                    }
                }
            }
Ejemplo n.º 3
0
            public void CreateRequest_ShouldParseValidTypeNames(string query, string expected)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters = HttpUtility.ParseQueryString(query);

                var request = processor.CreateRequest(parameters);

                if (expected != null)
                {
                    var exNames = expected
                                  .Split(',')
                                  .Select <string, XName>(n => XName.Get(n));

                    Assert.NotNull(request.TypeName);

                    // Cannot seem to be able to use the request.TypeName property here...

                    var elementNames = from el in request.Untyped.Descendants()
                                       where el.Name == "{http://www.opengis.net/cat/csw/2.0.2}TypeName"
                                       select el;
                    var xen = elementNames.Select <XElement, XName>(
                        e => (Discovery.GetXmlNameFromString(e.Value, e))
                        );

                    Assert.Equal <int>(exNames.Count <XName>(), xen.Count <XName>());
                    foreach (XName n in exNames)
                    {
                        Assert.Contains <XName>(n, xen);
                    }
                }
            }
Ejemplo n.º 4
0
            public void CreateRequest_ShouldThrowOnInvalidParameters(string query)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters = HttpUtility.ParseQueryString(query);

                Assert.Throws <OwsException>(() => processor.CreateRequest(parameters));
            }
Ejemplo n.º 5
0
            public void CreateRequest_ShouldParseValidOutputFormat(string query, string expected)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters = HttpUtility.ParseQueryString(query);

                var request = processor.CreateRequest(parameters);

                Assert.Equal <string>(expected, request.outputFormat);
            }
Ejemplo n.º 6
0
            public void CheckRequest_ShouldThrowWhenSchemaLanguageIsInvalid(string language)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var request = new DescribeRecord()
                {
                    schemaLanguage = (language != null ? new Uri(language) : null)
                };

                Assert.Throws <OwsException>(() => processor.CheckRequest(request));
            }
Ejemplo n.º 7
0
            public void CheckRequest_ShouldThrowWhenOutputFormatIsInvalid(string format)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var request = new DescribeRecord()
                {
                    outputFormat = format
                };

                Assert.Throws <OwsException>(() => processor.CheckRequest(request));
            }
Ejemplo n.º 8
0
            public void CreateRequest_ShouldParseValidSchemaLanguage(string query, string expected)
            {
                var discovery = new Mock <Discovery>();
                var processor = new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters = HttpUtility.ParseQueryString(query);

                var request = processor.CreateRequest(parameters);

                if (expected != null)
                {
                    var exUri = new Uri(expected);
                    Assert.Equal <Uri>(exUri, request.schemaLanguage);
                }
                else
                {
                    Assert.Null(request.schemaLanguage);
                }
            }
Ejemplo n.º 9
0
            public void CreateRequest_ShouldParseValidTypeNames(string query, string expected)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters=HttpUtility.ParseQueryString(query);

                var request=processor.CreateRequest(parameters);

                if (expected!=null)
                {
                    var exNames=expected
                        .Split(',')
                        .Select<string, XName>(n => XName.Get(n));

                    Assert.NotNull(request.TypeName);

                    // Cannot seem to be able to use the request.TypeName property here...

                    var elementNames=from el in request.Untyped.Descendants()
                                     where el.Name=="{http://www.opengis.net/cat/csw/2.0.2}TypeName"
                                     select el;
                    var xen=elementNames.Select<XElement, XName>(
                        e => (Discovery.GetXmlNameFromString(e.Value, e))
                    );

                    Assert.Equal<int>(exNames.Count<XName>(), xen.Count<XName>());
                    foreach (XName n in exNames)
                        Assert.Contains<XName>(n, xen);
                }
            }
Ejemplo n.º 10
0
            public void CheckRequest_ShouldThrowWhenSchemaLanguageIsInvalid(string language)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var request=new DescribeRecord() {
                    schemaLanguage=(language!=null ? new Uri(language) : null)
                };

                Assert.Throws<OwsException>(() => processor.CheckRequest(request));
            }
Ejemplo n.º 11
0
            public void CheckRequest_ShouldThrowWhenOutputFormatIsInvalid(string format)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var request=new DescribeRecord()
                {
                    outputFormat=format
                };

                Assert.Throws<OwsException>(() => processor.CheckRequest(request));
            }
Ejemplo n.º 12
0
            public void CreateRequest_ShouldThrowOnInvalidParameters(string query)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters=HttpUtility.ParseQueryString(query);

                Assert.Throws<OwsException>(() => processor.CreateRequest(parameters));
            }
Ejemplo n.º 13
0
            public void CreateRequest_ShouldParseValidSchemaLanguage(string query, string expected)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters=HttpUtility.ParseQueryString(query);

                var request=processor.CreateRequest(parameters);

                if (expected!=null)
                {
                    var exUri=new Uri(expected);
                    Assert.Equal<Uri>(exUri, request.schemaLanguage);
                } else
                    Assert.Null(request.schemaLanguage);
            }
Ejemplo n.º 14
0
            public void CreateRequest_ShouldParseValidOutputFormat(string query, string expected)
            {
                var discovery=new Mock<Discovery>();
                var processor=new DescribeRecordProcessorAccessor(discovery.Object);

                var parameters=HttpUtility.ParseQueryString(query);

                var request=processor.CreateRequest(parameters);

                Assert.Equal<string>(expected, request.outputFormat);
            }