From 8d259c60d9acd6a41434344f3c407b6cdfd05015 Mon Sep 17 00:00:00 2001 From: Tomas Bruckner Date: Fri, 26 Jun 2020 20:43:01 +0200 Subject: [PATCH 1/3] [1.2.0] improved configuration --- .../Core/Settings/SnapshotSettings.cs | 95 +++++++++++++++++++ .../JestDotnet/Core/SnapshotConstants.cs | 9 -- .../JestDotnet/Core/SnapshotResolver.cs | 18 +++- JestDotnet/JestDotnet/JestAssert.cs | 3 +- JestDotnet/JestDotnet/JestDotnet.csproj | 2 +- JestDotnet/JestDotnet/JestDotnetExtensions.cs | 3 +- JestDotnet/XUnitTests/SettingsTests.cs | 74 +++++++++++++++ ...sTestsShouldMatchCustomSnapExtension.snap2 | 6 ++ ...ttingsTestsShouldMatchLinuxLineEnding.snap | 6 ++ ...ingsTestsShouldMatchWindowsLineEnding.snap | 6 ++ README.md | 37 ++++++++ 11 files changed, 242 insertions(+), 17 deletions(-) create mode 100644 JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs delete mode 100644 JestDotnet/JestDotnet/Core/SnapshotConstants.cs create mode 100644 JestDotnet/XUnitTests/SettingsTests.cs create mode 100644 JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchCustomSnapExtension.snap2 create mode 100644 JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchLinuxLineEnding.snap create mode 100644 JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchWindowsLineEnding.snap diff --git a/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs b/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs new file mode 100644 index 0000000..7cb330a --- /dev/null +++ b/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs @@ -0,0 +1,95 @@ +using System; +using System.Globalization; +using System.IO; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace JestDotnet.Core.Settings +{ + public static class SnapshotSettings + { + /// + /// Default snapshot extension + /// + public const string DefaultSnapshotExtension = "snap"; + + /// + /// default snapshot directory + /// + public const string DefaultSnapshotDirectory = "__snapshots__"; + + /// + /// snapshot extension + /// + public static string SnapshotExtension = DefaultSnapshotExtension; + + /// + /// snapshot directory + /// + public static string SnapshotDirectory = DefaultSnapshotDirectory; + + /// + /// default snapshot dot extension creator + /// + public static readonly Func DefaultCreateSnapshotDotExtension = () => $".{SnapshotExtension}"; + + /// + /// snapshot dot extension creator + /// + public static Func CreateSnapshotDotExtension = DefaultCreateSnapshotDotExtension; + + /// + /// default function that creates snapshot path + /// + public static readonly Func<(string sourceFilePath, string memberName, string hint), string> DefaultCreatePath = + SnapshotResolver.CreatePath; + + /// + /// function that creates snapshot path + /// + public static Func<(string sourceFilePath, string memberName, string hint), string> CreatePath = + DefaultCreatePath; + + /// + /// default JSON serializer creator + /// + public static readonly Func DefaultCreateJsonSerializer = JsonSerializer.CreateDefault; + + /// + /// JSON serializer creator + /// + public static Func CreateJsonSerializer = DefaultCreateJsonSerializer; + + /// + /// default JToken writer creator + /// + public static readonly Func DefaultCreateJTokenWriter = () => new JTokenWriter(); + + /// + /// JToken writer creator + /// + public static Func CreateJTokenWriter = DefaultCreateJTokenWriter; + + /// + /// default string writer creator + /// + public static readonly Func DefaultCreateStringWriter = + () => new StringWriter(CultureInfo.InvariantCulture); + + /// + /// string writer creator + /// + public static Func CreateStringWriter = DefaultCreateStringWriter; + + /// + /// default text writer creator + /// + public static readonly Func DefaultCreateTextWriter = stringWriter => + new JsonTextWriter(stringWriter) {Formatting = Formatting.Indented}; + + /// + /// text writer creator + /// + public static Func CreateTextWriter = DefaultCreateTextWriter; + } +} diff --git a/JestDotnet/JestDotnet/Core/SnapshotConstants.cs b/JestDotnet/JestDotnet/Core/SnapshotConstants.cs deleted file mode 100644 index b2150c9..0000000 --- a/JestDotnet/JestDotnet/Core/SnapshotConstants.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace JestDotnet.Core -{ - internal static class SnapshotConstants - { - public const string SnapshotExtension = "snap"; - public const string SnapshotDirectory = "__snapshots__"; - public static readonly string SnapshotDotExtension = $".{SnapshotExtension}"; - } -} diff --git a/JestDotnet/JestDotnet/Core/SnapshotResolver.cs b/JestDotnet/JestDotnet/Core/SnapshotResolver.cs index e6cb6c6..2db3a5e 100644 --- a/JestDotnet/JestDotnet/Core/SnapshotResolver.cs +++ b/JestDotnet/JestDotnet/Core/SnapshotResolver.cs @@ -1,5 +1,5 @@ using System.IO; -using Newtonsoft.Json.Linq; +using JestDotnet.Core.Settings; namespace JestDotnet.Core { @@ -12,16 +12,24 @@ internal static string GetSnapshotData(string path) internal static void StoreSnapshotData(string path, object actualObject) { - var serialized = JToken.FromObject(actualObject).ToString(); + var jsonSerializer = SnapshotSettings.CreateJsonSerializer(); + using var jsonWriter = SnapshotSettings.CreateJTokenWriter(); + jsonSerializer.Serialize(jsonWriter, actualObject); + using var stringWriter = SnapshotSettings.CreateStringWriter(); + using var jsonTextWriter = SnapshotSettings.CreateTextWriter(stringWriter); + jsonWriter.Token!.WriteTo(jsonTextWriter); + var serialized = stringWriter.ToString(); + Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllText(path, serialized); } - internal static string CreatePath(string sourceFilePath, string memberName, string hint) + internal static string CreatePath((string sourceFilePath, string memberName, string hint) args) { - var directoryName = $"{Path.GetDirectoryName(sourceFilePath)}/{SnapshotConstants.SnapshotDirectory}"; + var (sourceFilePath, memberName, hint) = args; + var directoryName = $"{Path.GetDirectoryName(sourceFilePath)}/{SnapshotSettings.SnapshotDirectory}"; var fileName = - $"{Path.GetFileNameWithoutExtension(sourceFilePath)}{memberName}{hint}{SnapshotConstants.SnapshotDotExtension}"; + $"{Path.GetFileNameWithoutExtension(sourceFilePath)}{memberName}{hint}{SnapshotSettings.CreateSnapshotDotExtension()}"; return $"{directoryName}/{fileName}"; } diff --git a/JestDotnet/JestDotnet/JestAssert.cs b/JestDotnet/JestDotnet/JestAssert.cs index 4c5c46f..9131902 100644 --- a/JestDotnet/JestDotnet/JestAssert.cs +++ b/JestDotnet/JestDotnet/JestAssert.cs @@ -2,6 +2,7 @@ using System.Runtime.CompilerServices; using JestDotnet.Core; using JestDotnet.Core.Exceptions; +using JestDotnet.Core.Settings; namespace JestDotnet { @@ -14,7 +15,7 @@ public static void ShouldMatchSnapshot( [CallerFilePath] string sourceFilePath = "" ) { - var path = SnapshotResolver.CreatePath(sourceFilePath, memberName, hint); + var path = SnapshotSettings.CreatePath((sourceFilePath, memberName, hint)); var snapshot = SnapshotResolver.GetSnapshotData(path); if (string.IsNullOrEmpty(snapshot)) diff --git a/JestDotnet/JestDotnet/JestDotnet.csproj b/JestDotnet/JestDotnet/JestDotnet.csproj index 1fb7228..a84ca79 100644 --- a/JestDotnet/JestDotnet/JestDotnet.csproj +++ b/JestDotnet/JestDotnet/JestDotnet.csproj @@ -2,7 +2,7 @@ netcoreapp3.1 - 1.1.0 + 1.2.0 Tomas Bruckner https://github.com/tomasbruckner/jest-dotnet Snapshot testing in C#. See Project Site for more details diff --git a/JestDotnet/JestDotnet/JestDotnetExtensions.cs b/JestDotnet/JestDotnet/JestDotnetExtensions.cs index 3e1acf1..97378d5 100644 --- a/JestDotnet/JestDotnet/JestDotnetExtensions.cs +++ b/JestDotnet/JestDotnet/JestDotnetExtensions.cs @@ -1,6 +1,7 @@ using System.Runtime.CompilerServices; using JestDotnet.Core; using JestDotnet.Core.Exceptions; +using JestDotnet.Core.Settings; namespace JestDotnet { @@ -13,7 +14,7 @@ public static void ShouldMatchSnapshot( [CallerFilePath] string sourceFilePath = "" ) { - var path = SnapshotResolver.CreatePath(sourceFilePath, memberName, hint); + var path = SnapshotSettings.CreatePath((sourceFilePath, memberName, hint)); var snapshot = SnapshotResolver.GetSnapshotData(path); if (string.IsNullOrEmpty(snapshot)) diff --git a/JestDotnet/XUnitTests/SettingsTests.cs b/JestDotnet/XUnitTests/SettingsTests.cs new file mode 100644 index 0000000..b3da8ef --- /dev/null +++ b/JestDotnet/XUnitTests/SettingsTests.cs @@ -0,0 +1,74 @@ +using System; +using System.Globalization; +using System.IO; +using JestDotnet; +using JestDotnet.Core.Settings; +using Xunit; +using XUnitTests.Helpers; + +namespace XUnitTests +{ + public class SettingsTests + { + [Fact] + public void ShouldMatchCustomSnapExtension() + { + SnapshotSettings.CreateStringWriter = () => new StringWriter(CultureInfo.InvariantCulture) + { + NewLine = "\n" + }; + + SnapshotSettings.SnapshotExtension = "snap2"; + + var testObject = new Person + { + Age = 13, + DateOfBirth = new DateTime(2008, 7, 7), + FirstName = "John", + LastName = "Bam" + }; + + JestAssert.ShouldMatchSnapshot(testObject); + + SnapshotSettings.SnapshotExtension = SnapshotSettings.DefaultSnapshotExtension; + } + + [Fact] + public void ShouldMatchLinuxLineEnding() + { + SnapshotSettings.CreateStringWriter = () => new StringWriter(CultureInfo.InvariantCulture) + { + NewLine = "\n" + }; + + var testObject = new Person + { + Age = 13, + DateOfBirth = new DateTime(2008, 7, 7), + FirstName = "John", + LastName = "Bam" + }; + + JestAssert.ShouldMatchSnapshot(testObject); + } + + [Fact] + public void ShouldMatchWindowsLineEnding() + { + SnapshotSettings.CreateStringWriter = () => new StringWriter(CultureInfo.InvariantCulture) + { + NewLine = "\r\n" + }; + + var testObject = new Person + { + Age = 13, + DateOfBirth = new DateTime(2008, 7, 7), + FirstName = "John", + LastName = "Bam" + }; + + JestAssert.ShouldMatchSnapshot(testObject); + } + } +} diff --git a/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchCustomSnapExtension.snap2 b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchCustomSnapExtension.snap2 new file mode 100644 index 0000000..778e258 --- /dev/null +++ b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchCustomSnapExtension.snap2 @@ -0,0 +1,6 @@ +{ + "FirstName": "John", + "LastName": "Bam", + "DateOfBirth": "2008-07-07T00:00:00", + "Age": 13 +} \ No newline at end of file diff --git a/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchLinuxLineEnding.snap b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchLinuxLineEnding.snap new file mode 100644 index 0000000..778e258 --- /dev/null +++ b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchLinuxLineEnding.snap @@ -0,0 +1,6 @@ +{ + "FirstName": "John", + "LastName": "Bam", + "DateOfBirth": "2008-07-07T00:00:00", + "Age": 13 +} \ No newline at end of file diff --git a/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchWindowsLineEnding.snap b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchWindowsLineEnding.snap new file mode 100644 index 0000000..3e2c458 --- /dev/null +++ b/JestDotnet/XUnitTests/__snapshots__/SettingsTestsShouldMatchWindowsLineEnding.snap @@ -0,0 +1,6 @@ +{ + "FirstName": "John", + "LastName": "Bam", + "DateOfBirth": "2008-07-07T00:00:00", + "Age": 13 +} \ No newline at end of file diff --git a/README.md b/README.md index cb10158..153b130 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,43 @@ var expected = new Person JestAssert.ShouldMatchObject(actual,expected); ``` +## Advanced +### Configuring directory and file extensions +If you need to configure it, you can use `SnapshotSettings` class to specify your own +* extension instead of `.snap` (use `SnapshotSettings.SnapshotExtension`) +* directory instead of `__snapshots__` (use `SnapshotSettings.SnapshotDirectory`) +* function that generates directory, extension and filename (use `SnapshotSettings.CreatePath`) + + +### Configuring serialization +For serialization, I am using Json.NET. If you need to configure it, you can use `SnapshotSettings` class to specify your own + +* `JsonSerializer` (use `SnapshotSettings.CreateJsonSerializer`) +* `JTokenWriter` (use `SnapshotSettings.CreateJTokenWriter`) +* `StringWriter` (use `SnapshotSettings.CreateStringWriter`) +* `JsonTextWriter` (use `SnapshotSettings.CreateJsonTextWriter`). + + Popular use is to change line ending of the `.snap` files. For example if you want to set line ending to Linux `LF`, you can do it like this: + +```csharp +SnapshotSettings.CreateStringWriter = () => new StringWriter(CultureInfo.InvariantCulture) +{ + NewLine = "\n" +}; + +var testObject = new Person +{ + Age = 13, + DateOfBirth = new DateTime(2008, 7, 7), + FirstName = "John", + LastName = "Bam" +}; + +JestAssert.ShouldMatchSnapshot(testObject); +``` + +`SnapshotSettings` expects you define your own function that returns new configured instance. + ## Caveats ### Dynamic objects You cannot call neither extension nor `JestAssert` with `dynamic` object. You need to cast it to `object` (or real type). From 3c7ba513377d647aad8fdd7f64e7f26412015682 Mon Sep 17 00:00:00 2001 From: Tomas Bruckner Date: Wed, 9 Dec 2020 17:16:38 +0100 Subject: [PATCH 2/3] support netstandard --- .../Core/Settings/SnapshotSettings.cs | 36 ++++++-- .../JestDotnet/Core/SnapshotResolver.cs | 11 ++- JestDotnet/JestDotnet/JestDotnet.csproj | 29 +++++-- JestDotnet/XUnitTests/ComplexObjectTest.cs | 82 ++++++++++++++++++ .../XUnitTests/Helpers/ComplexObject.cs | 31 +++++++ JestDotnet/XUnitTests/XUnitTests.csproj | 12 +-- ...lexObjectTestShouldMatchDynamicObject.snap | 42 +++++++++ JestDotnet/jest.png | Bin 0 -> 5532 bytes README.md | 5 ++ 9 files changed, 225 insertions(+), 23 deletions(-) create mode 100644 JestDotnet/XUnitTests/ComplexObjectTest.cs create mode 100644 JestDotnet/XUnitTests/Helpers/ComplexObject.cs create mode 100644 JestDotnet/XUnitTests/__snapshots__/ComplexObjectTestShouldMatchDynamicObject.snap create mode 100644 JestDotnet/jest.png diff --git a/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs b/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs index 7cb330a..488a4aa 100644 --- a/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs +++ b/JestDotnet/JestDotnet/Core/Settings/SnapshotSettings.cs @@ -31,7 +31,8 @@ public static class SnapshotSettings /// /// default snapshot dot extension creator /// - public static readonly Func DefaultCreateSnapshotDotExtension = () => $".{SnapshotExtension}"; + public static readonly Func DefaultCreateSnapshotDotExtension = + () => $".{SnapshotExtension}"; /// /// snapshot dot extension creator @@ -41,19 +42,22 @@ public static class SnapshotSettings /// /// default function that creates snapshot path /// - public static readonly Func<(string sourceFilePath, string memberName, string hint), string> DefaultCreatePath = - SnapshotResolver.CreatePath; + public static readonly Func<(string sourceFilePath, string memberName, string hint), string> + DefaultCreatePath = + SnapshotResolver.CreatePath; /// /// function that creates snapshot path /// - public static Func<(string sourceFilePath, string memberName, string hint), string> CreatePath = - DefaultCreatePath; + public static Func<(string sourceFilePath, string memberName, string hint), string> + CreatePath = + DefaultCreatePath; /// /// default JSON serializer creator /// - public static readonly Func DefaultCreateJsonSerializer = JsonSerializer.CreateDefault; + public static readonly Func DefaultCreateJsonSerializer = + JsonSerializer.CreateDefault; /// /// JSON serializer creator @@ -63,7 +67,8 @@ public static class SnapshotSettings /// /// default JToken writer creator /// - public static readonly Func DefaultCreateJTokenWriter = () => new JTokenWriter(); + public static readonly Func DefaultCreateJTokenWriter = + () => new JTokenWriter(); /// /// JToken writer creator @@ -84,12 +89,25 @@ public static class SnapshotSettings /// /// default text writer creator /// - public static readonly Func DefaultCreateTextWriter = stringWriter => - new JsonTextWriter(stringWriter) {Formatting = Formatting.Indented}; + public static readonly Func DefaultCreateTextWriter = + stringWriter => + new JsonTextWriter(stringWriter) {Formatting = Formatting.Indented}; /// /// text writer creator /// public static Func CreateTextWriter = DefaultCreateTextWriter; + + /// + /// default stream writer creator + /// + public static Func DefaultCreateStreamWriter = + path => new StreamWriter(path, true); + + + /// + /// stream writer creator + /// + public static Func CreateStreamWriter = DefaultCreateStreamWriter; } } diff --git a/JestDotnet/JestDotnet/Core/SnapshotResolver.cs b/JestDotnet/JestDotnet/Core/SnapshotResolver.cs index 2db3a5e..6757cc5 100644 --- a/JestDotnet/JestDotnet/Core/SnapshotResolver.cs +++ b/JestDotnet/JestDotnet/Core/SnapshotResolver.cs @@ -21,13 +21,18 @@ internal static void StoreSnapshotData(string path, object actualObject) var serialized = stringWriter.ToString(); Directory.CreateDirectory(Path.GetDirectoryName(path)); - File.WriteAllText(path, serialized); + + using var sw = SnapshotSettings.CreateStreamWriter(path); + sw.Write(serialized); } - internal static string CreatePath((string sourceFilePath, string memberName, string hint) args) + internal static string CreatePath( + (string sourceFilePath, string memberName, string hint) args + ) { var (sourceFilePath, memberName, hint) = args; - var directoryName = $"{Path.GetDirectoryName(sourceFilePath)}/{SnapshotSettings.SnapshotDirectory}"; + var directoryName = + $"{Path.GetDirectoryName(sourceFilePath)}/{SnapshotSettings.SnapshotDirectory}"; var fileName = $"{Path.GetFileNameWithoutExtension(sourceFilePath)}{memberName}{hint}{SnapshotSettings.CreateSnapshotDotExtension()}"; diff --git a/JestDotnet/JestDotnet/JestDotnet.csproj b/JestDotnet/JestDotnet/JestDotnet.csproj index a84ca79..9f683dd 100644 --- a/JestDotnet/JestDotnet/JestDotnet.csproj +++ b/JestDotnet/JestDotnet/JestDotnet.csproj @@ -1,22 +1,39 @@ - netcoreapp3.1 - 1.2.0 + net47;netcoreapp2.1;netcoreapp3.1;net50;netstandard2.0;netstandard2.1 + 1.3.0 Tomas Bruckner + true https://github.com/tomasbruckner/jest-dotnet + true + 1591;1573 + False Snapshot testing in C#. See Project Site for more details https://github.com/tomasbruckner/jest-dotnet MIT - testing, test, snapshot, jest, json, xunit - latest + jest.png + See https://github.com/tomasbruckner/jest-dotnet/releases + testing;test;snapshot;jest;json;xunit;netcore;netstandard + + Simple snapshot testing with inspiration from amazing Jest library. + true + git@github.com:tomasbruckner/jest-dotnet.git + git true + Copyright Tomas Bruckner 2020 + 8.0 - - + + + + + + + diff --git a/JestDotnet/XUnitTests/ComplexObjectTest.cs b/JestDotnet/XUnitTests/ComplexObjectTest.cs new file mode 100644 index 0000000..d7dcdd8 --- /dev/null +++ b/JestDotnet/XUnitTests/ComplexObjectTest.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using JestDotnet; +using Xunit; +using XUnitTests.Helpers; + +namespace XUnitTests +{ + public class ComplexObjectTests + { + [Fact] + public void ShouldMatchDynamicObject() + { + var testObject = new ComplexObject + { + BoolValue = false, + IntValue = 123, + StringValue = string.Empty, + ChildObject = new ChildObject + { + IntValue = 33, + StringValue = "child" + }, + DateTimeValue = DateTime.MaxValue, + IntNullValue = null, + Children = new Dictionary + { + { + "first", new DictionaryChildObject + { + IntValue = 312, + StringValue1 = "nested1", + StringValue2 = null, + IntNullValue = null, + ReadOnlyDictionaryChildren = new Dictionary + { + {"key1", false}, + {"key2", true}, + { + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key1", + true + }, + {"Рикроллинг", true}, + { + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key3", + true + }, + { + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key4", + true + }, + {"4", true} + } + } + }, + { + "second", new DictionaryChildObject + { + IntValue = 312, + StringValue1 = "nested2", + StringValue2 = "x", + IntNullValue = 4, + ReadOnlyDictionaryChildren = new Dictionary() + } + }, + { + "third", new DictionaryChildObject + { + IntValue = 312, + StringValue1 = "nested2", + StringValue2 = "x", + IntNullValue = 4, + ReadOnlyDictionaryChildren = null + } + } + } + }; + + JestAssert.ShouldMatchSnapshot(testObject); + } + } +} diff --git a/JestDotnet/XUnitTests/Helpers/ComplexObject.cs b/JestDotnet/XUnitTests/Helpers/ComplexObject.cs new file mode 100644 index 0000000..29bdfa9 --- /dev/null +++ b/JestDotnet/XUnitTests/Helpers/ComplexObject.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace XUnitTests.Helpers +{ + public class ComplexObject + { + public IDictionary Children { get; set; } + public ChildObject ChildObject { get; set; } + public bool BoolValue { get; set; } + public int IntValue { get; set; } + public DateTime? DateTimeValue { get; set; } + public string StringValue { get; set; } + public int? IntNullValue { get; set; } + } + + public class DictionaryChildObject + { + public IReadOnlyDictionary ReadOnlyDictionaryChildren { get; set; } + public int IntValue { get; set; } + public string StringValue1 { get; set; } + public string StringValue2 { get; set; } + public int? IntNullValue { get; set; } + } + + public class ChildObject + { + public int IntValue { get; set; } + public string StringValue { get; set; } + } +} diff --git a/JestDotnet/XUnitTests/XUnitTests.csproj b/JestDotnet/XUnitTests/XUnitTests.csproj index 30adb97..133f907 100644 --- a/JestDotnet/XUnitTests/XUnitTests.csproj +++ b/JestDotnet/XUnitTests/XUnitTests.csproj @@ -1,15 +1,17 @@ - netcoreapp3.1 + net47;netcoreapp2.1;netcoreapp3.1;net50 false - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/JestDotnet/XUnitTests/__snapshots__/ComplexObjectTestShouldMatchDynamicObject.snap b/JestDotnet/XUnitTests/__snapshots__/ComplexObjectTestShouldMatchDynamicObject.snap new file mode 100644 index 0000000..34ddc4d --- /dev/null +++ b/JestDotnet/XUnitTests/__snapshots__/ComplexObjectTestShouldMatchDynamicObject.snap @@ -0,0 +1,42 @@ +{ + "Children": { + "first": { + "ReadOnlyDictionaryChildren": { + "key1": false, + "key2": true, + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key1": true, + "Рикроллинг": true, + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key3": true, + "very.very.very.very.very.very.very.very.very.very.very.very.very.long.key4": true, + "4": true + }, + "IntValue": 312, + "StringValue1": "nested1", + "StringValue2": null, + "IntNullValue": null + }, + "second": { + "ReadOnlyDictionaryChildren": {}, + "IntValue": 312, + "StringValue1": "nested2", + "StringValue2": "x", + "IntNullValue": 4 + }, + "third": { + "ReadOnlyDictionaryChildren": null, + "IntValue": 312, + "StringValue1": "nested2", + "StringValue2": "x", + "IntNullValue": 4 + } + }, + "ChildObject": { + "IntValue": 33, + "StringValue": "child" + }, + "BoolValue": false, + "IntValue": 123, + "DateTimeValue": "9999-12-31T23:59:59.9999999", + "StringValue": "", + "IntNullValue": null +} \ No newline at end of file diff --git a/JestDotnet/jest.png b/JestDotnet/jest.png new file mode 100644 index 0000000000000000000000000000000000000000..2b18a730f743598f10e1bbf50d61fdb4583cb36b GIT binary patch literal 5532 zcmeHL_cI&-(-xg57lPBBoF2XRn#1Y6_a5~)T|y8}a=6Ihq9n>WAqdf*<&i5fR^-#6*-N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wEaz^^V=8g9zLuR3Ix8)nhqP_lw)95PD< z*9#Lj&(d|KE|~t5oTZ}F0~Zeqw@dNSssgP}`YU;Dque6h22oAVYF}TX`*{$>5 z`4nl9h35kI>OoZkN&}a8?mb>Na}OM??^4QWdV)-jLNQo)?On++?(dX3)uRALP@%f| zpeV*mPre)0`JcXkiT*4MHqw zq0)Tz`N6|FWZS-@3SelX6Z-u+?Fe3Sw@h^ds&p`y2c zyEt@jBI8=Gs1;3V6rAWfmoxrZ+ybS+V$OSL#ge=auHMejIjk=Go*VDOrZq59YPI*E zj@&FDw&GszZ-bXjGFt9a3kG!p&3Aia6LRjqP1A`@b07MeSKEC`T>blH^0t1R+fsTh z|J6I1y{BO3^Pm@AA`U&3TlGMQSv)vtL&!RPG=a8n5IET60uq9k+Pwy&yLdj+i;*+WNGq=BXx<5r~ui(W&l(#vpb;E z5lWfl_E}d@GkcL}tq?->tGjGJp%Fc}qe$T#qF!b`uhh*rg0=MaFo@C~G#;$$^d zd89}5du!l|VVwAma8wU`L=8fBTL~jJ;WGl%q9k z#~)DCqRmn5@YG85=tN)5^98Lv`}L#($f&R~XJP}%QDqwH#$G3L&WZcb#beVfQiEJi!4aK7= z&3jB^^okU*iEockr#wuJ*i=Wd3c)hO+XD}!b)d^PX|87+{`{(?eCxKSVP!9=1spD-FtK(>94BGjF{)P+7V3%%4klXG z@O8L~ff0r=J+vs-rir++a8OTG(V1Ez>9NwVJT=2)RNkJJo~gEP`=^I`rcZp^nNZ75 zAFZV)kem)E)%K{&3>B)jrnq&S z$1NON7opwz!N8+B)fQ!9A(~=an~ck&t8#CscsZh3m)G<5!Vv0i&aWP@L!jvtVv{O?ap|B Date: Wed, 9 Dec 2020 17:27:05 +0100 Subject: [PATCH 3/3] version 1.3.1 --- JestDotnet/JestDotnet/JestDotnet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JestDotnet/JestDotnet/JestDotnet.csproj b/JestDotnet/JestDotnet/JestDotnet.csproj index 9f683dd..2eb24ad 100644 --- a/JestDotnet/JestDotnet/JestDotnet.csproj +++ b/JestDotnet/JestDotnet/JestDotnet.csproj @@ -2,7 +2,7 @@ net47;netcoreapp2.1;netcoreapp3.1;net50;netstandard2.0;netstandard2.1 - 1.3.0 + 1.3.1 Tomas Bruckner true https://github.com/tomasbruckner/jest-dotnet