Example #1
0
        public void BasicHttpBinding_Error()
        {
            var label = new TestLabel("BasicHttpBinding_Error");

            var doc         = TestContext.LoadMetadata("http-error.xml");
            var sd          = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;
            var wsdlBinding = sd.Bindings [0];

            var importer = new WsdlImporter(doc);

            label.EnterScope("all");

            var bindings = importer.ImportAllBindings();

            Assert.That(bindings, Is.Not.Null, label.Get());
            Assert.That(bindings.Count, Is.EqualTo(0), label.Get());

            label.EnterScope("errors");
            Assert.That(importer.Errors, Is.Not.Null, label.Get());
            Assert.That(importer.Errors.Count, Is.EqualTo(1), label.Get());

            var error = importer.Errors [0];

            Assert.That(error.IsWarning, Is.False, label.Get());
            label.LeaveScope();
            label.LeaveScope();

            label.EnterScope("single");

            try {
                importer.ImportBinding(wsdlBinding);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            Assert.That(importer.Errors.Count, Is.EqualTo(1), label.Get());

            label.LeaveScope();

            label.EnterScope("single-first");

            var importer2 = new WsdlImporter(doc);

            try {
                importer2.ImportBinding(wsdlBinding);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            Assert.That(importer2.Errors.Count, Is.EqualTo(1), label.Get());

            try {
                importer2.ImportBinding(wsdlBinding);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            var bindings2 = importer.ImportAllBindings();

            Assert.That(bindings2, Is.Not.Null, label.Get());
            Assert.That(bindings2.Count, Is.EqualTo(0), label.Get());

            label.LeaveScope();
        }
Example #2
0
        public void BasicHttpBinding_Error2()
        {
            var label = new TestLabel("BasicHttpBinding_Error2");

            var doc = TestContext.LoadMetadata("http-error.xml");
            var sd  = (WS.ServiceDescription)doc.MetadataSections [0].Metadata;

            label.EnterScope("wsdl");
            Assert.That(sd.Services, Is.Not.Null, label.Get());
            Assert.That(sd.Services.Count, Is.EqualTo(1), label.Get());

            var service = sd.Services [0];

            Assert.That(service.Ports, Is.Not.Null, label.Get());
            Assert.That(service.Ports.Count, Is.EqualTo(1), label.Get());
            label.LeaveScope();

            var importer = new WsdlImporter(doc);

            label.EnterScope("all");

            var endpoints = importer.ImportAllEndpoints();

            Assert.That(endpoints, Is.Not.Null, label.Get());
            Assert.That(endpoints.Count, Is.EqualTo(0), label.Get());

            label.EnterScope("errors");
            Assert.That(importer.Errors, Is.Not.Null, label.Get());
            Assert.That(importer.Errors.Count, Is.EqualTo(2), label.Get());

            Assert.That(importer.Errors [0].IsWarning, Is.False, label.Get());
            Assert.That(importer.Errors [1].IsWarning, Is.False, label.Get());
            label.LeaveScope();
            label.LeaveScope();

            label.EnterScope("single");

            try {
                importer.ImportEndpoint(service.Ports [0]);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            Assert.That(importer.Errors.Count, Is.EqualTo(2), label.Get());

            label.LeaveScope();

            label.EnterScope("single-first");

            var importer2 = new WsdlImporter(doc);

            try {
                importer2.ImportEndpoint(service.Ports [0]);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            Assert.That(importer2.Errors.Count, Is.EqualTo(2), label.Get());

            try {
                importer2.ImportEndpoint(service.Ports [0]);
                Assert.Fail(label.Get());
            } catch {
                ;
            }

            var endpoints2 = importer.ImportAllEndpoints();

            Assert.That(endpoints2, Is.Not.Null, label.Get());
            Assert.That(endpoints2.Count, Is.EqualTo(0), label.Get());

            label.LeaveScope();
        }