Esempio n. 1
0
        public void Uri_ShouldReturnARelativeUriByDefault()
        {
            var uri = new UriBuilderWrapper().Uri;

            Assert.IsFalse(uri.IsAbsolute);
            Assert.AreEqual("/", uri.OriginalString);
        }
        public void Uri_Get_IfTheQueryHasBeenSetWithALeadingQuestionMark_ShouldReturnAnUriWithoutDoubleLeadingQuestionMarks()
        {
            var uriBuilderWrapper = new UriBuilderWrapper
            {
                Query = "?Key=Value"
            };

            Assert.AreEqual("/?Key=Value", uriBuilderWrapper.Uri.ToString());
        }
        public void Uri_Get_IfTheFragmentHasBeenSetWithALeadingHashSign_ShouldReturnAnUriWithoutDoubleLeadingHashSigns()
        {
            var uriBuilderWrapper = new UriBuilderWrapper
            {
                Fragment = "#Test"
            };

            Assert.AreEqual("/#Test", uriBuilderWrapper.Uri.ToString());
        }
Esempio n. 4
0
        public void Uri_Get_IfConstructedWithAnInitialUriAndTheQueryHasBeenSet_ShouldReturnAnUriWithTheQuery()
        {
            var uriBuilderWrapper = new UriBuilderWrapper("http://localhost/")
            {
                Query = "Key=Value"
            };

            Assert.AreEqual("http://localhost/?Key=Value", uriBuilderWrapper.Uri.ToString());
        }
Esempio n. 5
0
        public void Uri_Get_IfConstructedWithAnInitialUriAndTheFragmentHasBeenSet_ShouldReturnAnUriWithTheFragment()
        {
            var uriBuilderWrapper = new UriBuilderWrapper("http://localhost/")
            {
                Fragment = "#Test"
            };

            Assert.AreEqual("http://localhost/#Test", uriBuilderWrapper.Uri.ToString());
        }
        public void Uri_Get_IfModified_ShouldSetModifiedToFalse()
        {
            var uriBuilderWrapper = new UriBuilderWrapper("http://localhost/")
            {
                Fragment = "#Test"
            };

            Assert.IsTrue(uriBuilderWrapper.Modified);

            _ = uriBuilderWrapper.Uri;

            Assert.IsFalse(uriBuilderWrapper.Modified);
        }
Esempio n. 7
0
        public void Password_Set_IfTheValueParameterIsNotNull_ShouldMakeItAbsolute()
        {
            var uriWrapper = new UriBuilderWrapper();

            Assert.IsFalse(uriWrapper.IsAbsolute);
            Assert.IsFalse(uriWrapper.Uri.IsAbsolute);

            uriWrapper.Password = null;

            Assert.IsFalse(uriWrapper.IsAbsolute);
            Assert.IsFalse(uriWrapper.Uri.IsAbsolute);

            uriWrapper.Password = string.Empty;

            Assert.IsTrue(uriWrapper.IsAbsolute);
            Assert.IsTrue(uriWrapper.Uri.IsAbsolute);
        }
Esempio n. 8
0
        public void Port_Set_IfTheValueParameterIsNotNull_ShouldMakeItAbsolute()
        {
            var uriWrapper = new UriBuilderWrapper();

            Assert.IsFalse(uriWrapper.IsAbsolute);
            Assert.IsFalse(uriWrapper.Uri.IsAbsolute);

            foreach (var number in new[] { -1, 0, 1, 5 })
            {
                uriWrapper.Port = null;

                Assert.IsFalse(uriWrapper.IsAbsolute);
                Assert.IsFalse(uriWrapper.Uri.IsAbsolute);

                uriWrapper.Port = number;

                Assert.IsTrue(uriWrapper.IsAbsolute);
                Assert.IsTrue(uriWrapper.Uri.IsAbsolute);
            }
        }