Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit cf9f0dc

Browse files
this is sad AF
1 parent 2dfa0ab commit cf9f0dc

5 files changed

Lines changed: 72 additions & 8 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
namespace SqlStreamStore.HAL.Tests
2+
{
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Text.RegularExpressions;
8+
using System.Threading.Tasks;
9+
using Newtonsoft.Json;
10+
using Newtonsoft.Json.Linq;
11+
using Shouldly;
12+
using Xunit;
13+
14+
public class AllJsonSchemasTests
15+
{
16+
private static Regex s_isSqlStreamStoreSchema = new Regex(@"Schema\.(.*)\.schema\.json$");
17+
18+
private static byte[] s_bom =
19+
{
20+
0xEF, 0xBB, 0xBF
21+
};
22+
23+
private static StreamReader GetStreamReader(string manifestName)
24+
=> new StreamReader(GetStream(manifestName));
25+
26+
private static Stream GetStream(string manifestName)
27+
=> typeof(SchemaSet<>)
28+
.GetTypeInfo()
29+
.Assembly
30+
.GetManifestResourceStream(manifestName);
31+
32+
public static IEnumerable<object[]> GetJsonSchemas() => from manifestName in typeof(SchemaSet<>)
33+
.GetTypeInfo()
34+
.Assembly
35+
.GetManifestResourceNames()
36+
where s_isSqlStreamStoreSchema.IsMatch(manifestName)
37+
select new[] { manifestName };
38+
39+
40+
[Theory, MemberData(nameof(GetJsonSchemas))]
41+
public async Task byte_order_mark_not_present(string manifestName)
42+
{
43+
byte[] firstThreeBytes = new byte[3];
44+
45+
using(var stream = GetStream(manifestName))
46+
{
47+
await stream.ReadAsync(firstThreeBytes);
48+
49+
firstThreeBytes.SequenceEqual(s_bom)
50+
.ShouldBeFalse();
51+
}
52+
}
53+
54+
[Theory, MemberData(nameof(GetJsonSchemas))]
55+
public void json_schema_is_compatible_with_markdown_generator(string manifestName)
56+
{
57+
using(var reader = GetStreamReader(manifestName))
58+
{
59+
JsonConvert.DeserializeObject<JObject>(reader.ReadToEnd()).Value<string>("$schema")
60+
.ShouldBe("http://json-schema.org/draft-07/schema#");
61+
}
62+
}
63+
}
64+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Delete Stream Message",
44
"type": "object"
55
}

src/SqlStreamStore.HAL/StreamMetadata/Schema/SetStreamMetadata.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{
1+
{
22
"title": "Set Stream Metadata",
33
"type": "object",
4-
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
4+
"$schema": "http://json-schema.org/draft-07/schema#",
55
"properties": {
66
"maxCount": {
77
"type": "integer",

src/SqlStreamStore.HAL/Streams/Schema/AppendToStream.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Append to Stream",
44
"type": "object",
55
"required": [
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"$schema": "http://json-schema.org/draft-07/hyper-schema#",
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
33
"title": "Delete Stream",
44
"type": "object"
55
}

0 commit comments

Comments
 (0)