Пример #1
0
        public static void Equal(Resource expected, Resource actual)
        {
            if (expected == null)
            {
                Assert.Null(actual);
                return;
            }
            Assert.NotNull(actual);

            // Type
            Assert.Equal(expected.Type, actual.Type);

            // Id
            Assert.Equal(expected.Id, actual.Id);

            // Attributes
            ApiObjectAssert.Equal(expected.Attributes, actual.Attributes);

            // Relationships
            RelationshipsAssert.Equal(expected.Relationships, actual.Relationships);

            // Links
            LinksAssert.Equal(expected.Links, actual.Links);

            // Meta
            MetaAssert.Equal(expected.Meta, actual.Meta);
        }
        // PUBLIC METHODS ///////////////////////////////////////////////////
        #region Assert Methods
        public static void Equal(Relationships expected, string actualJson)
        {
            Assert.NotNull(expected);
            Assert.False(String.IsNullOrEmpty(actualJson));

            var actualJToken = JToken.Parse(actualJson);

            RelationshipsAssert.Equal(expected, actualJToken);
        }
Пример #3
0
        public static void Equal(Resource 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;

            // Type
            Assert.Equal(expected.Type, (string)actualJObject.SelectToken(Keywords.Type));

            // Id
            Assert.Equal(expected.Id, (string)actualJObject.SelectToken(Keywords.Id));

            // Attributes
            var actualAttributesJToken = actualJObject.SelectToken(Keywords.Attributes);

            ApiObjectAssert.Equal(expected.Attributes, actualAttributesJToken);

            // Relationships
            var actualRelationshipsJToken = actualJObject.SelectToken(Keywords.Relationships);

            RelationshipsAssert.Equal(expected.Relationships, actualRelationshipsJToken);

            // Links
            var actualLinksJToken = actualJObject.SelectToken(Keywords.Links);

            LinksAssert.Equal(expected.Links, actualLinksJToken);

            // Meta
            var actualMetaJToken = actualJObject.SelectToken(Keywords.Meta);

            MetaAssert.Equal(expected.Meta, actualMetaJToken);
        }
        public static void Equal(IEnumerable <Relationships> expected, IEnumerable <Relationships> 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 expectedRelationships = expectedCollection[index];
                var actualRelationships   = actualCollection[index];

                RelationshipsAssert.Equal(expectedRelationships, actualRelationships);
            }
        }