Skip to content

Commit

Permalink
Fix normalised git line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanSaeed committed Jun 8, 2022
1 parent 73461cb commit 5e16326
Show file tree
Hide file tree
Showing 13 changed files with 2,608 additions and 2,608 deletions.
896 changes: 448 additions & 448 deletions .editorconfig

Large diffs are not rendered by default.

364 changes: 182 additions & 182 deletions README.md

Large diffs are not rendered by default.

358 changes: 179 additions & 179 deletions Schema.NET.sln

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions Tests/Schema.NET.Test/ContextJsonConverterTest.cs
Original file line number Diff line number Diff line change
@@ -1,73 +1,73 @@
namespace Schema.NET.Test;

using Xunit;

public class ContextJsonConverterTest
{
[Fact]
public void ReadJson_StringContext_ContextHasName()
{
var json = "{\"@context\":\"foo\",\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Null(thing?.Context.Language);
}

[Fact]
public void ReadJson_ObjectContextWithName_ContextHasName()
{
var json = "{\"@context\":{\"name\":\"foo\"},\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Null(thing?.Context.Language);
}

[Fact]
public void ReadJson_ObjectContextWithNameAndLanguage_ContextHasNameAndLanguage()
{
var json = "{\"@context\":{\"name\":\"foo\",\"@language\":\"en\"},\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Equal("en", thing?.Context.Language);
}

[Fact]
public void ReadJson_ArrayContextWithNameAndLanguage_ContextHasNameAndLanguage()
{
var json = "{\"@context\":[\"foo\",{\"@language\":\"en\"}],\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Equal("en", thing?.Context.Language);
}

[Fact]
public void WriteJson_StringContext_ContextHasName()
{
var json = new Thing().ToString();

Assert.Equal("{\"@context\":\"https://schema.org\",\"@type\":\"Thing\"}", json);
}

[Fact]
public void WriteJson_ObjectContextWithLanguage_ContextHasName()
{
var thing = new Thing();
thing.Context.Language = "en";

var json = thing.ToString();

Assert.Equal("{\"@context\":{\"name\":\"https://schema.org\",\"@language\":\"en\"},\"@type\":\"Thing\"}", json);
}
}
namespace Schema.NET.Test;

using Xunit;

public class ContextJsonConverterTest
{
[Fact]
public void ReadJson_StringContext_ContextHasName()
{
var json = "{\"@context\":\"foo\",\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Null(thing?.Context.Language);
}

[Fact]
public void ReadJson_ObjectContextWithName_ContextHasName()
{
var json = "{\"@context\":{\"name\":\"foo\"},\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Null(thing?.Context.Language);
}

[Fact]
public void ReadJson_ObjectContextWithNameAndLanguage_ContextHasNameAndLanguage()
{
var json = "{\"@context\":{\"name\":\"foo\",\"@language\":\"en\"},\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Equal("en", thing?.Context.Language);
}

[Fact]
public void ReadJson_ArrayContextWithNameAndLanguage_ContextHasNameAndLanguage()
{
var json = "{\"@context\":[\"foo\",{\"@language\":\"en\"}],\"@type\":\"Thing\"}";

var thing = SchemaSerializer.DeserializeObject<Thing>(json);

Assert.NotNull(thing?.Context);
Assert.Equal("foo", thing?.Context.Name);
Assert.Equal("en", thing?.Context.Language);
}

[Fact]
public void WriteJson_StringContext_ContextHasName()
{
var json = new Thing().ToString();

Assert.Equal("{\"@context\":\"https://schema.org\",\"@type\":\"Thing\"}", json);
}

[Fact]
public void WriteJson_ObjectContextWithLanguage_ContextHasName()
{
var thing = new Thing();
thing.Context.Language = "en";

var json = thing.ToString();

Assert.Equal("{\"@context\":{\"name\":\"https://schema.org\",\"@language\":\"en\"},\"@type\":\"Thing\"}", json);
}
}
132 changes: 66 additions & 66 deletions Tests/Schema.NET.Test/JsonLdContextTest.cs
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
namespace Schema.NET.Test;

using System.Collections.Generic;
using Xunit;

public class JsonLdContextTest
{
public static IEnumerable<object[]> EqualContexts => new List<object[]>
{
new object[] { new JsonLdContext(), new JsonLdContext() },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "a" } },
new object[]
{
new JsonLdContext() { Name = "a", Language = "b" },
new JsonLdContext() { Name = "a", Language = "b" },
},
};

public static IEnumerable<object[]> NotEqualContexts => new List<object[]>
{
new object[] { new JsonLdContext(), null! },
new object[] { new JsonLdContext(), new JsonLdContext() { Name = "a" } },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "b" } },
new object[]
{
new JsonLdContext() { Name = "a", Language = "b" },
new JsonLdContext() { Name = "a", Language = "c" },
},
};

public static IEnumerable<object[]> ToStringContexts => new List<object[]>
{
new object[] { new JsonLdContext(), "https://schema.org" },
new object[] { new JsonLdContext() { Name = "a" }, "a" },
};

[Theory]
[MemberData(nameof(EqualContexts))]
public void Equals_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a.Equals(b));

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void Equals_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a.Equals(b));

[Theory]
[MemberData(nameof(EqualContexts))]
public void EqualsOperator_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a == b);

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void EqualsOperator_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a == b);

[Theory]
[MemberData(nameof(EqualContexts))]
public void NotEqualsOperator_IsEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a != b);

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void NotEqualsOperator_IsNotEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a != b);

[Theory]
[MemberData(nameof(ToStringContexts))]
public void ToString_MatchesExpected_ReturnsName(JsonLdContext context, string expectedValue) =>
Assert.Equal(expectedValue, context.ToString());
}
namespace Schema.NET.Test;

using System.Collections.Generic;
using Xunit;

public class JsonLdContextTest
{
public static IEnumerable<object[]> EqualContexts => new List<object[]>
{
new object[] { new JsonLdContext(), new JsonLdContext() },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "a" } },
new object[]
{
new JsonLdContext() { Name = "a", Language = "b" },
new JsonLdContext() { Name = "a", Language = "b" },
},
};

public static IEnumerable<object[]> NotEqualContexts => new List<object[]>
{
new object[] { new JsonLdContext(), null! },
new object[] { new JsonLdContext(), new JsonLdContext() { Name = "a" } },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() },
new object[] { new JsonLdContext() { Name = "a" }, new JsonLdContext() { Name = "b" } },
new object[]
{
new JsonLdContext() { Name = "a", Language = "b" },
new JsonLdContext() { Name = "a", Language = "c" },
},
};

public static IEnumerable<object[]> ToStringContexts => new List<object[]>
{
new object[] { new JsonLdContext(), "https://schema.org" },
new object[] { new JsonLdContext() { Name = "a" }, "a" },
};

[Theory]
[MemberData(nameof(EqualContexts))]
public void Equals_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a.Equals(b));

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void Equals_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a.Equals(b));

[Theory]
[MemberData(nameof(EqualContexts))]
public void EqualsOperator_IsEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a == b);

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void EqualsOperator_IsNotEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a == b);

[Theory]
[MemberData(nameof(EqualContexts))]
public void NotEqualsOperator_IsEqual_ReturnsFalse(JsonLdContext a, JsonLdContext b) => Assert.False(a != b);

[Theory]
[MemberData(nameof(NotEqualContexts))]
public void NotEqualsOperator_IsNotEqual_ReturnsTrue(JsonLdContext a, JsonLdContext b) => Assert.True(a != b);

[Theory]
[MemberData(nameof(ToStringContexts))]
public void ToString_MatchesExpected_ReturnsName(JsonLdContext context, string expectedValue) =>
Assert.Equal(expectedValue, context.ToString());
}
Loading

0 comments on commit 5e16326

Please sign in to comment.