|
6 | 6 |
|
7 | 7 | using NUnit.Framework; |
8 | 8 |
|
9 | | -namespace Xtensive.Orm.Tests.Core |
| 9 | +namespace Xtensive.Orm.Tests.Core; |
| 10 | + |
| 11 | +[TestFixture] |
| 12 | +public class UrlInfoTest |
10 | 13 | { |
11 | | - [TestFixture] |
12 | | - public class UrlInfoTest |
| 14 | + [Test] |
| 15 | + public void CombinedTest() |
13 | 16 | { |
14 | | - [Test] |
15 | | - public void CombinedTest() |
16 | | - { |
17 | | - UrlInfo a1 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter=someValue&someParameter2=someValue2"); |
18 | | - UrlInfo a2 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter=someValue&someParameter2=someValue2"); |
19 | | - UrlInfo aX = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter2=someValue2&someParameter=someValue"); |
20 | | - UrlInfo b = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl"); |
| 17 | + UrlInfo a1 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter=someValue&someParameter2=someValue2"); |
| 18 | + UrlInfo a2 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter=someValue&someParameter2=someValue2"); |
| 19 | + UrlInfo aX = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?someParameter2=someValue2&someParameter=someValue"); |
| 20 | + UrlInfo b = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl"); |
| 21 | + |
| 22 | + Assert.IsTrue(a1.GetHashCode()==a2.GetHashCode()); |
| 23 | + Assert.IsTrue(a1.GetHashCode()!=b.GetHashCode()); |
21 | 24 |
|
22 | | - Assert.IsTrue(a1.GetHashCode()==a2.GetHashCode()); |
23 | | - Assert.IsTrue(a1.GetHashCode()!=b.GetHashCode()); |
| 25 | + Assert.IsTrue(a1.Equals(a2)); |
| 26 | + Assert.IsFalse(a1.Equals(b)); |
| 27 | + } |
24 | 28 |
|
25 | | - Assert.IsTrue(a1.Equals(a2)); |
26 | | - Assert.IsFalse(a1.Equals(b)); |
27 | | - } |
| 29 | + [Test] |
| 30 | + public void WithTest() |
| 31 | + { |
| 32 | + UrlInfo a1 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?p3=v3&p4=v4&p1=v1&p2=v2"); |
| 33 | + var a2 = a1 with { |
| 34 | + Port = 2000, |
| 35 | + Password = "xxx", |
| 36 | + Protocol = "unkProto", |
| 37 | + Resource = "other/resource", |
| 38 | + Params = new Dictionary<string, string> { { "a", "b" } } |
| 39 | + }; |
| 40 | + Assert.AreEqual("unkProto://user:xxx@someHost:2000/other/resource?a=b", a2.ToString()); |
| 41 | + Assert.IsTrue(a2.Equals(a2)); |
| 42 | + Assert.IsFalse(a1.Equals(a2)); |
| 43 | + var a3 = UrlInfo.Parse("unkProto://user:xxx@someHost:2000/other/resource?a=b"); |
| 44 | + Assert.IsTrue(a2 == a3); |
| 45 | + } |
28 | 46 |
|
29 | | - [Test] |
30 | | - public void WithTest() |
31 | | - { |
32 | | - UrlInfo a1 = UrlInfo.Parse("tcp://user:password@someHost:1000/someUrl/someUrl?p3=v3&p4=v4&p1=v1&p2=v2"); |
33 | | - var a2 = a1 with { Port = 2000 }; |
34 | | - Assert.AreEqual("tcp://user:password@someHost:2000/someUrl/someUrl?p1=v1&p2=v2&p3=v3&p4=v4", a2.ToString()); |
35 | | - Assert.IsTrue(a2.Equals(a2)); |
36 | | - Assert.IsFalse(a1.Equals(a2)); |
37 | | - var a3 = UrlInfo.Parse("tcp://user:password@someHost:2000/someUrl/someUrl?p1=v1&p2=v2&p3=v3&p4=v4"); |
38 | | - Assert.IsTrue(a2 == a3); |
39 | | - } |
| 47 | + [Test] |
| 48 | + public void TestUrlProps() |
| 49 | + { |
| 50 | + var url = UrlInfo.Parse("sqlserver://int:[email protected]:51571/db"); |
| 51 | + Assert.AreEqual("sqlserver", url.Protocol); |
| 52 | + Assert.AreEqual("int", url.User); |
| 53 | + Assert.AreEqual("xxx", url.Password); |
| 54 | + Assert.AreEqual("127.0.0.1", url.Host); |
| 55 | + Assert.AreEqual(51571, url.Port); |
| 56 | + Assert.AreEqual("db", url.Resource); |
40 | 57 | } |
41 | 58 | } |
0 commit comments