예제 #1
0
        public void TestLinkParse(string name, Link expected)
        {
            // Arrange
            var json = expected.ToJson();

            // Act
            this.Output.WriteLine(json);
            var actual = JsonObject.Parse <Link>(json);

            // Assert
            LinkAssert.Equal(expected, actual);
        }
예제 #2
0
        public void TestLinkToJson(string name, Link expected)
        {
            // Arrange

            // Act
            var actual = expected.ToJson();

            this.Output.WriteLine(actual);

            // Assert
            LinkAssert.Equal(expected, actual);
        }
예제 #3
0
        public void TestLinkConversionOperatorToLinkFromString()
        {
            // Arrange
            var json     = ApiSampleData.ArticleCollectionHRef;
            var expected = new Link(ApiSampleData.ArticleCollectionHRef);

            // Act
            this.Output.WriteLine(json);
            var actual = (Link)json;

            // Assert
            LinkAssert.Equal(expected, actual);
        }
예제 #4
0
        public void TestLinksGetLinkWithLinkThatExists()
        {
            // Arrange
            var links = new Links
            {
                { Keywords.Up, ApiSampleData.ArticleCollectionLink },
                { Keywords.Self, ApiSampleData.ArticleLink }
            };

            // Act
            var expected = ApiSampleData.ArticleLink;
            var actual   = links.GetLink(Keywords.Self);

            // Assert
            LinkAssert.Equal(expected, actual);
        }
예제 #5
0
        public void TestLinksTryGetLinkWithLinkThatExists()
        {
            // Arrange
            var links = new Links
            {
                { Keywords.Up, ApiSampleData.ArticleCollectionLink },
                { Keywords.Self, ApiSampleData.ArticleLink }
            };

            // Act
            var  expected = ApiSampleData.ArticleLink;
            Link actual;
            var  foundLink = links.TryGetLink(Keywords.Self, out actual);

            // Assert
            Assert.True(foundLink);
            LinkAssert.Equal(expected, actual);
        }
예제 #6
0
        internal void TestIDomLinkAbstraction(string name, string expectedRel, Link expectedLink, IDomLink domLink)
        {
            // Arrange

            // Act
            this.Output.WriteLine("Test Name: {0}", name);
            this.Output.WriteLine(String.Empty);
            this.Output.WriteLine("Expected Rel:  {0}", expectedRel);
            this.Output.WriteLine("Expected Link: {0}", expectedLink);

            this.Output.WriteLine(String.Empty);

            var actualRel  = domLink.Rel;
            var actualLink = domLink.Link;

            this.Output.WriteLine("Actual Rel:    {0}", actualRel);
            this.Output.WriteLine("Actual Link:   {0}", actualLink);

            // Assert
            Assert.Equal(expectedRel, actualRel);
            LinkAssert.Equal(expectedLink, actualLink);
        }
예제 #7
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Assert Methods
        public static void Equal(string expectedRel, Link expectedLink, DomReadOnlyLink actual)
        {
            if (String.IsNullOrWhiteSpace(expectedRel))
            {
                Assert.Null(actual);
                return;
            }
            Assert.NotNull(actual);
            Assert.NotNull(expectedLink);

            Assert.Equal(DomNodeType.Link, actual.NodeType);

            // Rel
            var actualRel = actual.Rel;

            Assert.Equal(expectedRel, actualRel);

            // Link
            var actualLink = actual.Link;

            LinkAssert.Equal(expectedLink, actualLink);
        }