-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adding mstest support Co-authored-by: Normen Scheiber <nscheibe@live.com>
- Loading branch information
1 parent
2df8eda
commit 1da1c90
Showing
33 changed files
with
2,240 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Snapshooter.MSTest.Tests | ||
{ | ||
[TestClass] | ||
public class MSTestAssertTests | ||
{ | ||
[TestMethod] | ||
public void Assert_AssertEqualText_AssertSuccessful() | ||
{ | ||
// arrange | ||
var snapshotAssert = new MSTestAssert(); | ||
|
||
// act & assert | ||
snapshotAssert.Assert("{Same}", "{Same}"); | ||
} | ||
|
||
[TestMethod] | ||
public void Assert_AssertUnequalText_ThrowsEqualException() | ||
{ | ||
// arrange | ||
var snapshotAssert = new MSTestAssert(); | ||
|
||
// act | ||
Action action = () => snapshotAssert.Assert("{Same}", "{Sme}"); | ||
|
||
// assert | ||
Assert.ThrowsException<AssertFailedException>(action); | ||
} | ||
} | ||
} |
128 changes: 128 additions & 0 deletions
128
src/Snapshooter.MSTest.Tests/MSTestSnapshotFullNameReaderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Snapshooter.MSTest.Tests | ||
{ | ||
[TestClass] | ||
public class MSTestSnapshotFullNameReaderTests | ||
{ | ||
[TestMethod] | ||
public void ReadSnapshotFullName_ResolveTestSnapshotFullName_ResolvedSuccessfully() | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTestSnapshotFullName_ResolvedSuccessfully)}"); | ||
} | ||
|
||
[TestMethod] | ||
public async Task ReadSnapshotFullName_ResolveTestSnapshotFullNameAsync_ResolvedSuccessfully() | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
await Task.Delay(1); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
await Task.Delay(1); | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTestSnapshotFullNameAsync_ResolvedSuccessfully)}"); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("testString1", 5)] | ||
[DataRow("testString2", 6)] | ||
[DataRow("testString3", 7)] | ||
public void ReadSnapshotFullName_ResolveTheorySnapshotName_NameResolvedWithoutInlineDataParameters( | ||
string param1, int param2) | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTheorySnapshotName_NameResolvedWithoutInlineDataParameters)}" + | ||
$"_{param1}_{param2}"); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataRow("testString1", 5)] | ||
[DataRow("testString2", 6)] | ||
[DataRow("testString3", 7)] | ||
public async Task ReadSnapshotFullName_ResolveTheorySnapshotNameAsync_NameResolvedWithoutInlineDataParameters( | ||
string param1, int param2) | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
await Task.Delay(1); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
await Task.Delay(1); | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTheorySnapshotNameAsync_NameResolvedWithoutInlineDataParameters)}" + | ||
$"_{param1}_{param2}"); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataSource(nameof(TestCases))] | ||
public void ReadSnapshotFullName_ResolveTheoryDataSnapshotName_NameResolvedWithoutInlineDataParameters( | ||
string param1, int param2) | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTheoryDataSnapshotName_NameResolvedWithoutInlineDataParameters)}" + | ||
$"_{param1}_{param2}"); | ||
} | ||
|
||
[DataTestMethod] | ||
[DataSource(nameof(TestCases))] | ||
public async Task ReadSnapshotFullName_ResolveTheoryDataSnapshotNameAsync_NameResolvedWithoutInlineDataParameters( | ||
string param1, int param2) | ||
{ | ||
// arrange | ||
var snapshotFullNameResolver = new MSTestSnapshotFullNameReader(); | ||
await Task.Delay(1); | ||
|
||
// act | ||
SnapshotFullName snapshotFullName = snapshotFullNameResolver.ReadSnapshotFullName(); | ||
|
||
// assert | ||
await Task.Delay(1); | ||
Assert.AreEqual(snapshotFullName.Filename, | ||
$"{nameof(MSTestSnapshotFullNameReaderTests)}." + | ||
$"{nameof(ReadSnapshotFullName_ResolveTheoryDataSnapshotNameAsync_NameResolvedWithoutInlineDataParameters)}" + | ||
$"_{param1}_{param2}"); | ||
} | ||
|
||
private static object[] TestCases => new object[] | ||
{ | ||
new object[] { "testString1", 5 }, | ||
new object[] { "testString2", 6 }, | ||
new object[] { "testString3", 7 } | ||
}; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Snapshooter.MSTest.Tests/Snapshooter.MSTest.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="$(CCTestProjectProps)" Condition="Exists('$(CCTestProjectProps)')" /> | ||
|
||
<PropertyGroup> | ||
<AssemblyName>Snapshooter.MSTest.Tests</AssemblyName> | ||
<RootNamespace>Snapshooter.MSTest.Tests</RootNamespace> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Snapshooter.MSTest\Snapshooter.MSTest.csproj" /> | ||
<ProjectReference Include="..\Snapshooter.Tests.Data\Snapshooter.Tests.Data.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using FluentAssertions; | ||
using Snapshooter.Tests.Data; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Snapshooter.MSTest.Tests | ||
{ | ||
[TestClass] | ||
public class SnapshotExtensionTests | ||
{ | ||
[TestMethod] | ||
public void MatchSnapshot_ShouldFluentAssertions_RemovesSubject() | ||
{ | ||
// arrange | ||
TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton().Build(); | ||
|
||
// act & assert | ||
testPerson.Should().MatchSnapshot(); | ||
} | ||
|
||
[TestMethod] | ||
public void MatchSnapshot_ShouldFluentAssertionsNameOf_RemovesSubject() | ||
{ | ||
// arrange | ||
TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton().Build(); | ||
|
||
// act & assert | ||
testPerson.Should().MatchSnapshot(nameof(MatchSnapshot_ShouldFluentAssertionsNameOf_RemovesSubject)); | ||
} | ||
|
||
[TestMethod("Test for issue #118")] | ||
public void MatchSnapshot_FluentAssertions_StringValue_ShouldRemovesSubject() | ||
{ | ||
// arrange | ||
string testValue = "Some text string"; | ||
|
||
// act & assert | ||
testValue.Should().MatchSnapshot(); | ||
} | ||
|
||
[TestMethod("Test for issue #118")] | ||
public void MatchSnapshot_FluentAssertions_DictionaryValue_ShouldRemovesSubject() | ||
{ | ||
// arrange | ||
var testCustomer = new List<Dictionary<string, object>> | ||
{ | ||
new Dictionary<string, object> | ||
{ | ||
{ "Id", 1 }, | ||
{ "Name", "Bla "}, | ||
{ "EmailAddress", "blabla@blabla.com" }, | ||
}, | ||
}; | ||
var testDictionary = new Dictionary<string, List<Dictionary<string, object>>>(); | ||
testDictionary.Add("Customer", testCustomer); | ||
|
||
// act & assert | ||
testDictionary.Should().MatchSnapshot(); | ||
} | ||
|
||
[TestMethod] | ||
public void MatchSnapshot_PlainExtension_CorrectSnapshot() | ||
{ | ||
// arrange | ||
TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton().Build(); | ||
|
||
// act & assert | ||
testPerson.MatchSnapshot(); | ||
} | ||
|
||
[TestMethod] | ||
public void MatchSnapshot_PlainExtensionAnonymousType_CorrectSnapshot() | ||
{ | ||
// arrange | ||
TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton().Build(); | ||
|
||
// act & assert | ||
new { foo = testPerson }.MatchSnapshot(); | ||
} | ||
|
||
[TestMethod] | ||
public void MatchSnapshot_ShouldFluentAssertionsAnonymousType_CorrectSnapshot() | ||
{ | ||
// arrange | ||
TestPerson testPerson = TestDataBuilder.TestPersonMarkWalton().Build(); | ||
|
||
// act & assert | ||
new { foo = testPerson }.Should().MatchSnapshot(); | ||
} | ||
|
||
[TestMethod] | ||
public void MatchSnapshot_Null_Throws() | ||
{ | ||
// arrange | ||
TestPerson testPerson = null; | ||
|
||
// act & assert | ||
Assert.ThrowsException<ArgumentNullException>(() => testPerson.MatchSnapshot()); | ||
} | ||
} | ||
} |
Oops, something went wrong.