Пример #1
0
        public void GetContractMessageParameter()
        {
            ContractDescription cd = ContractDescription.GetContract(typeof(IMessageParameter));

            ServiceAssert.AssertContractDescription(
                "IMessageParameter", "http://tempuri.org/",
                SessionMode.Allowed, typeof(IMessageParameter), null,
                cd, "contract");

            OperationDescription od = cd.Operations [0];

            ServiceAssert.AssertOperationDescription(
                "ReturnMessage", null, null,
                typeof(IMessageParameter).GetMethod("ReturnMessage"),
                true, false, false,
                od, "operation");

            MessageDescription md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IMessageParameter/ReturnMessage",
                MessageDirection.Input,
                // Body.WrapperName is null
                null, null, null, false,
                md, "ReturnMessage");

            ServiceAssert.AssertMessagePartDescription(
                "arg", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(Message), md.Body.Parts [0], "ReturnMessage input");
        }
Пример #2
0
        public void TestContractFromObject()
        {
            ContractDescription cd = ContractDescription.GetContract(typeof(Foo));

            ServiceAssert.AssertContractDescription(typeof(IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null, cd, "#1");
            Assert.AreEqual(cd.Operations.Count, 2);
            OperationBehaviorAttribute op = cd.Operations.Find("HeyHey").Behaviors.Find <OperationBehaviorAttribute> ();

            Assert.IsNotNull(op);
            Assert.AreEqual(
                op.ReleaseInstanceMode,
                ReleaseInstanceMode.None, "#2");

            cd = ContractDescription.GetContract(typeof(IFoo), typeof(Foo));
            ServiceAssert.AssertContractDescription(typeof(IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null, cd, "#3");
            Assert.AreEqual(cd.Operations.Count, 2, "#4");
            Assert.AreEqual(
                cd.Operations.Find("HeyHey").Behaviors.Find <OperationBehaviorAttribute> ().ReleaseInstanceMode,
                ReleaseInstanceMode.AfterCall, "#5");
        }
Пример #3
0
        public void InternalTestGetContract(ContractDescription cd)
        {
            ServiceAssert.AssertContractDescription(
                "IFoo", "http://tempuri.org/", SessionMode.Allowed, typeof(IFoo), null,
                cd, "contract");

            Assert.AreEqual(2, cd.Operations.Count, "Operation count");

            // Operation #1
            OperationDescription od = cd.Operations [0];

            ServiceAssert.AssertOperationDescription(
                "HeyDude", null, null,
                typeof(IFoo).GetMethod("HeyDude"),
                true, false, false,
                od, "HeyDude");

            // Operation #1 -> Message #1
            MessageDescription md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyDude",
                MessageDirection.Input,
                null, "HeyDude", "http://tempuri.org/", false,
                md, "HeyDude");

            ServiceAssert.AssertMessagePartDescription(
                "msg", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyDude.msg");
            ServiceAssert.AssertMessagePartDescription(
                "msg2", "http://tempuri.org/", 1, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [1], "HeyDude.msg");

            // Operation #1 -> Message #2
            md = od.Messages [1];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyDudeResponse",
                MessageDirection.Output,
                null, "HeyDudeResponse",
                "http://tempuri.org/", true,
                md, "HeyDude");

            ServiceAssert.AssertMessagePartDescription(
                "HeyDudeResult", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.ReturnValue, "HeyDudeResponse ReturnValue");

            // Operation #2
            od = cd.Operations [1];

            ServiceAssert.AssertOperationDescription(
                "HeyHey", null, null,
                typeof(IFoo).GetMethod("HeyHey"),
                true, false, false,
                od, "HeyHey");

            // Operation #2 -> Message #1
            md = od.Messages [0];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyHey",
                MessageDirection.Input,
                null, "HeyHey", "http://tempuri.org/", false,
                md, "HeyHey");

            ServiceAssert.AssertMessagePartDescription(
                "ref1", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyHey.ref1");

            // Operation #2 -> Message #2
            md = od.Messages [1];

            ServiceAssert.AssertMessageAndBodyDescription(
                "http://tempuri.org/IFoo/HeyHeyResponse",
                MessageDirection.Output,
                null, "HeyHeyResponse",
                "http://tempuri.org/", true,
                md, "HeyHey");

            ServiceAssert.AssertMessagePartDescription(
                "HeyHeyResult", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(void), md.Body.ReturnValue, "HeyHeyResponse ReturnValue");

            ServiceAssert.AssertMessagePartDescription(
                "out1", "http://tempuri.org/", 0, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [0], "HeyHey.out1");
            ServiceAssert.AssertMessagePartDescription(
                "ref1", "http://tempuri.org/", 1, false,
                ProtectionLevel.None, typeof(string), md.Body.Parts [1], "HeyHey.ref1");
        }