示例#1
0
        public void ShouldDetermineBaseUrl()
        {
            //Act
            var desc = ServiceDescription.Create(typeof(IContract));

            //Assert
            Assert.Equal("http://foo", desc.Url);
        }
示例#2
0
        public void ShouldCalculateRightUrl(Type contractType, string methodName, string baseAddress, string expectedUrl)
        {
            //Arrange
            var srvDesc = ServiceDescription.Create(contractType);

            var method = contractType.GetMethod(methodName);

            var mDesc = srvDesc.Methods
                        .Where(kv => kv.Key == method.MetadataToken)
                        .Select(kv => kv.Value)
                        .First();

            var reqMsgBuilder = new HttpRequestMessageBuilder(baseAddress, mDesc);

            //Act
            var reqMsg = reqMsgBuilder.Build();

            //Assert
            Assert.Equal(expectedUrl, reqMsg.RequestUri.OriginalString);
        }
示例#3
0
 public void ShouldFailIfApiAttributeIsAbsent()
 {
     Assert.Throws <ApiContractException>(() => ServiceDescription.Create(typeof(IContractWithoutApiAttr)));
 }