Exemplo n.º 1
0
        public void HttpOperationDescription_Insert_OutputParameters_From_HttpOperationDescription()
        {
            OperationDescription             od      = GetOperationDescription(typeof(MockService2), "OneInOneOutReturnsString");
            MessagePartDescriptionCollection mpdColl = od.Messages[1].Body.Parts;

            Assert.AreEqual(1, mpdColl.Count, "Test assumes we start with 1 output param");

            // Get a synchronized HOD and HODCollection
            HttpOperationDescription           hod     = od.ToHttpOperationDescription();
            HttpParameterDescriptionCollection hpdColl = hod.OutputParameters;

            // Get an HPD for the newly created MPD
            MessagePartDescription mpdNew = new MessagePartDescription("NewMPD", "NewMPDNS")
            {
                Type = typeof(byte)
            };
            HttpParameterDescription hpd = mpdNew.ToHttpParameterDescription();

            // Add it to the output parameters
            hpdColl.Add(hpd);

            // Verify it appears in the MPD coll
            Assert.AreEqual(2, mpdColl.Count, "Adding new MPD to HPD collection should have updated MPD collection");
            Assert.AreEqual(2, od.Messages[1].Body.Parts.Count, "Adding new MPD should have updated Parts");
            Assert.AreEqual(typeof(byte), od.Messages[1].Body.Parts[1].Type, "Adding new MPD failed due to type");
        }
        public void HttpParameterDescription_ExtensionMethod_Throws_Null_MessagePartDescription()
        {
            MessagePartDescription mpd = null;

            ExceptionAssert.ThrowsArgumentNull(
                "Null MessagePartDescription should throw",
                "description",
                () => mpd.ToHttpParameterDescription()
                );
        }
        public void HttpParameterDescription_ExtensionMethod_Creates_From_MessagePartDescription()
        {
            OperationDescription     od  = GetOperationDescription(typeof(MockService3), "SampleMethod");
            MessagePartDescription   mpd = od.Messages[1].Body.ReturnValue;
            HttpParameterDescription hpd = mpd.ToHttpParameterDescription();

            Assert.AreEqual("SampleMethodResult", hpd.Name, "Name was not set correctly");
            Assert.AreEqual(typeof(string), hpd.ParameterType, "ProcessorType was not set correctly");
            Assert.AreEqual(0, hpd.Index, "Index was not set correctly");
            Assert.AreSame(mpd, hpd.MessagePartDescription, "Internal messagePartDescription should be what we passed to ctor");
        }