|
| 1 | +namespace Schema.NET.Test |
| 2 | +{ |
| 3 | + using System.Collections.Generic; |
| 4 | + using Xunit; |
| 5 | + |
| 6 | + public class JsonLdContextTest |
| 7 | + { |
| 8 | + public static IEnumerable<object[]> EqualContexts => new List<object[]> |
| 9 | + { |
| 10 | + new object[] { new JsonLdContext(), new JsonLdContext() }, |
| 11 | + new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "a" } }, |
| 12 | + new object[] |
| 13 | + { |
| 14 | + new JsonLdContext() { Name = "a", Language = "b" }, |
| 15 | + new JsonLdContext() { Name = "a", Language = "b" }, |
| 16 | + }, |
| 17 | + }; |
| 18 | + |
| 19 | + public static IEnumerable<object[]> NotEqualContexts => new List<object[]> |
| 20 | + { |
| 21 | + new object[] { new JsonLdContext(), null }, |
| 22 | + new object[] { new JsonLdContext(), new JsonLdContext() { Name = "a" } }, |
| 23 | + new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() }, |
| 24 | + new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "b" } }, |
| 25 | + new object[] |
| 26 | + { |
| 27 | + new JsonLdContext() { Name = "a", Language = "b" }, |
| 28 | + new JsonLdContext() { Name = "a", Language = "c" }, |
| 29 | + }, |
| 30 | + }; |
| 31 | + |
| 32 | + public static IEnumerable<object[]> ToStringContexts => new List<object[]> |
| 33 | + { |
| 34 | + new object[] { new JsonLdContext(), "http://schema.org" }, |
| 35 | + new object[] { new JsonLdContext() { Name = "a" }, "a" }, |
| 36 | + }; |
| 37 | + |
| 38 | + [Theory] |
| 39 | + [MemberData(nameof(EqualContexts))] |
| 40 | + public void Equals_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a.Equals(b)); |
| 41 | + |
| 42 | + [Theory] |
| 43 | + [MemberData(nameof(NotEqualContexts))] |
| 44 | + public void Equals_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a.Equals(b)); |
| 45 | + |
| 46 | + [Theory] |
| 47 | + [MemberData(nameof(EqualContexts))] |
| 48 | + public void EqualsOperator_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a == b); |
| 49 | + |
| 50 | + [Theory] |
| 51 | + [MemberData(nameof(NotEqualContexts))] |
| 52 | + public void EqualsOperator_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a == b); |
| 53 | + |
| 54 | + [Theory] |
| 55 | + [MemberData(nameof(EqualContexts))] |
| 56 | + public void NotEqualsOperator_IsEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a != b); |
| 57 | + |
| 58 | + [Theory] |
| 59 | + [MemberData(nameof(NotEqualContexts))] |
| 60 | + public void NotEqualsOperator_IsNotEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a != b); |
| 61 | + |
| 62 | + [Theory] |
| 63 | + [MemberData(nameof(ToStringContexts))] |
| 64 | + public void ToString_(JsonLdContext context, string expectedValue) => |
| 65 | + Assert.Equal(expectedValue, context.ToString()); |
| 66 | + } |
| 67 | +} |
0 commit comments