Skip to content

Commit

Permalink
Merge pull request #2 from tomasbruckner/version-1-3-1
Browse files Browse the repository at this point in the history
Version 1.3.1
  • Loading branch information
tomasbruckner authored Dec 9, 2020
2 parents c06291c + d7aa99f commit 46993df
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 11 deletions.
29 changes: 23 additions & 6 deletions JestDotnet/JestDotnet/JestDotnet.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,39 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>1.2.0</Version>
<TargetFrameworks>net47;netcoreapp2.1;netcoreapp3.1;net50;netstandard2.0;netstandard2.1</TargetFrameworks>
<Version>1.3.1</Version>
<Authors>Tomas Bruckner</Authors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RepositoryUrl>https://github.com/tomasbruckner/jest-dotnet</RepositoryUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>1591;1573</NoWarn>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Description>Snapshot testing in C#. See Project Site for more details</Description>
<PackageProjectUrl>https://github.com/tomasbruckner/jest-dotnet</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>testing, test, snapshot, jest, json, xunit</PackageTags>
<LangVersion>latest</LangVersion>
<PackageIcon>jest.png</PackageIcon>
<PackageReleaseNotes>See https://github.com/tomasbruckner/jest-dotnet/releases</PackageReleaseNotes>
<PackageTags>testing;test;snapshot;jest;json;xunit;netcore;netstandard</PackageTags>
<PackageDescription>
Simple snapshot testing with inspiration from amazing Jest library.
</PackageDescription>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>[email protected]:tomasbruckner/jest-dotnet.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<IncludeSymbols>true</IncludeSymbols>
<Copyright>Copyright Tomas Bruckner 2020</Copyright>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JsonDiffPatch.Net" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<None Include="..\jest.png" Pack="true" Visible="false" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="JsonDiffPatch.Net" Version="2.3.0"/>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
</ItemGroup>

</Project>
82 changes: 82 additions & 0 deletions JestDotnet/XUnitTests/ComplexObjectTest.cs
Original file line number Diff line number Diff line change
@@ -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<string, DictionaryChildObject>
{
{
"first", new DictionaryChildObject
{
IntValue = 312,
StringValue1 = "nested1",
StringValue2 = null,
IntNullValue = null,
ReadOnlyDictionaryChildren = new Dictionary<string, bool>
{
{"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<string, bool>()
}
},
{
"third", new DictionaryChildObject
{
IntValue = 312,
StringValue1 = "nested2",
StringValue2 = "x",
IntNullValue = 4,
ReadOnlyDictionaryChildren = null
}
}
}
};

JestAssert.ShouldMatchSnapshot(testObject);
}
}
}
31 changes: 31 additions & 0 deletions JestDotnet/XUnitTests/Helpers/ComplexObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;

namespace XUnitTests.Helpers
{
public class ComplexObject
{
public IDictionary<string, DictionaryChildObject> 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<string, bool> 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; }
}
}
12 changes: 7 additions & 5 deletions JestDotnet/XUnitTests/XUnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>net47;netcoreapp2.1;netcoreapp3.1;net50</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3"/>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Binary file added JestDotnet/jest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,8 @@ JestAssert.ShouldMatchSnapshot(testObject);
## Caveats
### Dynamic objects
You cannot call neither extension nor `JestAssert` with `dynamic` object. You need to cast it to `object` (or real type).


## Credits

[Package icon](https://www.flaticon.com/free-icon/joker-hat_68335)

0 comments on commit 46993df

Please sign in to comment.