예제 #1
0
        public void FromType_Type_Ok()
        {
            Type           actualType    = typeof(string);
            IUrlSerializer urlSerializer = UrlSerializer.FromType(actualType);

            Assert.Equal(1, urlSerializer.QueryParams.Count);
            Assert.Equal(actualType.Name, urlSerializer.GetTypeValue());
        }
예제 #2
0
        public void FromQueryParams_QueryParams_Ok()
        {
            const string        TypeValue   = "GetClientRequest";
            string              query       = string.Format("?type={0}&id=4DA2F891-953F-4637-AE83-6791688EAFA2&country=NL", TypeValue);
            NameValueCollection queryParams = HttpUtility.ParseQueryString(query);

            IUrlSerializer urlSerializer = UrlSerializer.FromQueryParams(queryParams);

            string actualType = urlSerializer.GetTypeValue();

            Assert.Equal(TypeValue, actualType);
            Assert.Equal(queryParams.Count, urlSerializer.QueryParams.Count);
        }
예제 #3
0
        public void FromValue_Value_Ok()
        {
            var request = new Request {
                Id = 1, Name = "Nelibur"
            };
            IUrlSerializer      urlSerializer = UrlSerializer.FromValue(request);
            NameValueCollection actual        = urlSerializer.QueryParams;

            Assert.Equal(3, urlSerializer.QueryParams.Count);
            var expected = new NameValueCollection
            {
                { RestServiceMetadata.ParamName.Type, "Request" },
                { "Id", "1" },
                { "Name", "Nelibur" }
            };

            Assert.Equal(ToKeyValue(expected), ToKeyValue(actual));
        }