Exemple #1
0
        public void ReplaceTest()
        {
            var uriValue = new UriValue("http://www.webapiclient.com");

            uriValue.Replace("a", "a", out var replaced);
            Assert.False(replaced);

            uriValue = new UriValue("http://www.webapiclient.com/path/?x={x}&y={Y}");
            uriValue = uriValue.Replace("x", "x", out replaced);
            Assert.True(replaced);
            Assert.Equal("http://www.webapiclient.com/path/?x=x&y={Y}", uriValue.ToString());

            uriValue = new UriValue("http://www.webapiclient.com/path/?x={x}&y={Y}");
            uriValue = uriValue.Replace("y", "y", out replaced);
            Assert.True(replaced);
            Assert.Equal("http://www.webapiclient.com/path/?x={x}&y=y", uriValue.ToString());
        }
Exemple #2
0
        public void AddQueryTest()
        {
            var uriValue = new UriValue("http://www.webapiclient.com");

            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/?a=a", uriValue.ToString());

            uriValue = new UriValue("http://www.webapiclient.com/path");
            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/path?a=a", uriValue.ToString());

            uriValue = new UriValue("http://www.webapiclient.com/path/");
            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/path/?a=a", uriValue.ToString());


            uriValue = new UriValue("http://www.webapiclient.com/path/?");
            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/path/?a=a", uriValue.ToString());

            uriValue = new UriValue("http://www.webapiclient.com/path?x=1");
            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/path?x=1&a=a", uriValue.ToString());


            uriValue = new UriValue("http://www.webapiclient.com/path?x=1&");
            uriValue = uriValue.AddQuery("a", "a");
            Assert.Equal("http://www.webapiclient.com/path?x=1&a=a", uriValue.ToString());

            uriValue = new UriValue("http://www.webapiclient.com/path?x=1&");
            uriValue = uriValue.AddQuery("a", "我");
            Assert.Equal($"http://www.webapiclient.com/path?x=1&a={Uri.EscapeDataString("我")}", uriValue.ToString());


            uriValue = new UriValue("http://www.webapiclient.com/path/?x=1&");
            uriValue = uriValue.AddQuery("a", "我");
            Assert.True(uriValue.ToString() == $"http://www.webapiclient.com/path/?x=1&a={Uri.EscapeDataString("我")}");
        }
Exemple #3
0
 public int CompareTo(Udi?other) => string.Compare(UriValue.ToString(), other?.UriValue.ToString(), StringComparison.OrdinalIgnoreCase);
Exemple #4
0
 public int CompareTo(Udi other)
 {
     return(string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.InvariantCultureIgnoreCase));
 }
Exemple #5
0
 public int CompareTo(Udi other)
 {
     return(string.Compare(UriValue.ToString(), other.UriValue.ToString(), StringComparison.OrdinalIgnoreCase));
 }
        public override bool Equals(object obj)
        {
            if (!(obj is ModelWithAllTypes to))
            {
                return(false);
            }

            if (ByteValue != to.ByteValue)
            {
                return(false);
            }
            if (CharValue != to.CharValue)
            {
                return(false);
            }
            if (CustomException.Message != to.CustomException.Message)
            {
                return(false);
            }
            if (DateTimeValue != to.DateTimeValue)
            {
                return(false);
            }
            if (DecimalValue != to.DecimalValue)
            {
                return(false);
            }
            if (DoubleValue != to.DoubleValue)
            {
                return(false);
            }
            if (Exception.Message != to.Exception.Message)
            {
                return(false);
            }
            if (FloatValue != to.FloatValue)
            {
                return(false);
            }
            if (IntValue != to.IntValue)
            {
                return(false);
            }
            if (LongValue != to.LongValue)
            {
                return(false);
            }
            if (SByteValue != to.SByteValue)
            {
                return(false);
            }
            if (ShortValue != to.ShortValue)
            {
                return(false);
            }
            if (TimeSpanValue != to.TimeSpanValue)
            {
                return(false);
            }
            if (TypeValue != to.TypeValue)
            {
                return(false);
            }
            if (UIntValue != to.UIntValue)
            {
                return(false);
            }
            if (ULongValue != to.ULongValue)
            {
                return(false);
            }
            if (UriValue.ToString() != to.UriValue.ToString())
            {
                return(false);
            }
            if (UShortValue != to.UShortValue)
            {
                return(false);
            }
            if (GuidValue != to.GuidValue)
            {
                return(false);
            }

            return(true);
        }