Esempio n. 1
0
        public static void Equal(Links expected, JToken actualJToken)
        {
            // Handle when 'expected' is null.
            if (expected == null)
            {
                ClrObjectAssert.IsNull(actualJToken);
                return;
            }

            // Handle when 'expected' is not null.
            Assert.NotNull(actualJToken);

            var actualJTokenType = actualJToken.Type;

            Assert.Equal(JTokenType.Object, actualJTokenType);

            var actualJObject = (JObject)actualJToken;

            var expectedLinksCount = expected.Count;
            var actualLinksCount   = actualJObject.Count;

            Assert.Equal(expectedLinksCount, actualLinksCount);

            foreach (var key in expected.Keys)
            {
                var expectedLink = expected[key];
                Assert.IsType <Link>(expectedLink);

                var actualLinkJToken = actualJObject[key];
                LinkAssert.Equal(expectedLink, actualLinkJToken);
            }
        }
Esempio n. 2
0
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Assert Methods
        public static void Equal(Link expected, string actualJson)
        {
            Assert.NotNull(expected);
            Assert.False(String.IsNullOrEmpty(actualJson));

            var actualJToken = JToken.Parse(actualJson);

            LinkAssert.Equal(expected, actualJToken);
        }
Esempio n. 3
0
        public static void Equal(IEnumerable <Link> expected, IEnumerable <Link> actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }
            Assert.NotNull(actual);

            var expectedCollection = expected.SafeToReadOnlyList();
            var actualCollection   = actual.SafeToReadOnlyList();

            Assert.Equal(expectedCollection.Count, actualCollection.Count);

            var count = expectedCollection.Count;

            for (var index = 0; index < count; ++index)
            {
                var expectedLink = expectedCollection[index];
                var actualLink   = actualCollection[index];

                LinkAssert.Equal(expectedLink, actualLink);
            }
        }
Esempio n. 4
0
        public static void Equal(Links expected, Links actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }

            Assert.NotNull(actual);
            Assert.Equal(expected.Count, actual.Count);

            foreach (var key in expected.Keys)
            {
                Assert.True(actual.ContainsKey(key));

                var expectedLink = expected[key];
                Assert.IsType <Link>(expectedLink);

                var actualLink = actual[key];
                Assert.IsType <Link>(actualLink);

                LinkAssert.Equal(expectedLink, actualLink);
            }
        }