Skip to content

Commit

Permalink
add unique for os (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 19, 2021
1 parent 08b5abb commit ef31825
Show file tree
Hide file tree
Showing 34 changed files with 155,324 additions and 19,965 deletions.
51 changes: 48 additions & 3 deletions docs/naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,24 @@ public class UniqueForSample
return Verifier.Verify("value")
.UniqueForArchitecture();
}

[Fact]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verifier.Verify("value", settings);
}

[Fact]
public Task OSPlatformFluent()
{
return Verifier.Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L6-L65' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs#L6-L80' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplexunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -275,9 +290,24 @@ public class UniqueForSample
return Verifier.Verify("value")
.UniqueForArchitecture();
}

[Test]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verifier.Verify("value", settings);
}

[Test]
public Task OSPlatformFluent()
{
return Verifier.Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs#L6-L72' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplenunit' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs#L6-L87' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplenunit' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -349,9 +379,24 @@ public class UniqueForSample :
return Verify("value")
.UniqueForArchitecture();
}

[TestMethod]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verify("value", settings);
}

[TestMethod]
public Task OSPlatformFluent()
{
return Verify("value")
.UniqueForOSPlatform();
}
}
```
<sup><a href='/src/Verify.MSTest.Tests/Snippets/UniqueForSample.cs#L6-L73' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplemstest' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.MSTest.Tests/Snippets/UniqueForSample.cs#L6-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-uniqueforsamplemstest' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down
175,060 changes: 155,114 additions & 19,946 deletions src/Naming/Tests.Test.verified.txt

Large diffs are not rendered by default.

50 changes: 35 additions & 15 deletions src/Naming/Tests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -26,6 +25,8 @@ public Task Test()
bool runVersionG,
bool arch,
bool archG,
bool os,
bool osG,
bool method,
bool type,
bool dir)
Expand All @@ -35,6 +36,7 @@ public Task Test()
sharedNamer.UniqueForRuntime = false;
sharedNamer.UniqueForRuntimeAndVersion = false;
sharedNamer.UniqueForArchitecture = false;
sharedNamer.UniqueForOSPlatform = false;

var directory = Path.Combine(Path.GetTempPath(), "VerifyNamer");
if (Directory.Exists(directory))
Expand Down Expand Up @@ -86,6 +88,16 @@ public Task Test()
VerifierSettings.UniqueForArchitecture();
}

if (os)
{
settings.UniqueForOSPlatform();
}

if (osG)
{
VerifierSettings.UniqueForOSPlatform();
}

if (method)
{
settings.UseMethodName("CustomMethod");
Expand Down Expand Up @@ -166,19 +178,27 @@ public IEnumerable<Result> BuildData()
{
foreach (var archStatic in bools)
{
yield return Run(
runtime,
runtimeStatic,
config,
configStatic,
runtimeVersion,
runtimeVersionStatic,
arch,
archStatic,
method,
type,
dir
);
foreach (var os in bools)
{
foreach (var osStatic in bools)
{
yield return Run(
runtime,
runtimeStatic,
config,
configStatic,
runtimeVersion,
runtimeVersionStatic,
arch,
archStatic,
os,
osStatic,
method,
type,
dir
);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
15 changes: 15 additions & 0 deletions src/Verify.MSTest.Tests/Snippets/UniqueForSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ public Task ArchitectureFluent()
return Verify("value")
.UniqueForArchitecture();
}

[TestMethod]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verify("value", settings);
}

[TestMethod]
public Task OSPlatformFluent()
{
return Verify("value")
.UniqueForOSPlatform();
}
}

#endregion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
15 changes: 15 additions & 0 deletions src/Verify.NUnit.Tests/Snippets/UniqueForSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ public Task ArchitectureFluent()
return Verifier.Verify("value")
.UniqueForArchitecture();
}

[Test]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verifier.Verify("value", settings);
}

[Test]
public Task OSPlatformFluent()
{
return Verifier.Verify("value")
.UniqueForOSPlatform();
}
}

#endregion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo
8 changes: 8 additions & 0 deletions src/Verify.Tests/Naming/NamerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,12 @@ public Task Architecture()
settings.UniqueForArchitecture();
return Verifier.Verify("Foo", settings);
}

[Fact]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verifier.Verify("Foo", settings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value
15 changes: 15 additions & 0 deletions src/Verify.Xunit.Tests/Snippets/UniqueForSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ public Task ArchitectureFluent()
return Verifier.Verify("value")
.UniqueForArchitecture();
}

[Fact]
public Task OSPlatform()
{
VerifySettings settings = new();
settings.UniqueForOSPlatform();
return Verifier.Verify("value", settings);
}

[Fact]
public Task OSPlatformFluent()
{
return Verifier.Verify("value")
.UniqueForOSPlatform();
}
}

#endregion
1 change: 0 additions & 1 deletion src/Verify.sln
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Global
{E39DAFA5-5BEF-44AA-BC40-EFAB817256F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E39DAFA5-5BEF-44AA-BC40-EFAB817256F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E39DAFA5-5BEF-44AA-BC40-EFAB817256F9}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{E39DAFA5-5BEF-44AA-BC40-EFAB817256F9}.Release|Any CPU.Build.0 = Debug|Any CPU
{6D2E5DA3-F22B-4D9A-B354-F4D346FCA7C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D2E5DA3-F22B-4D9A-B354-F4D346FCA7C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D2E5DA3-F22B-4D9A-B354-F4D346FCA7C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
5 changes: 5 additions & 0 deletions src/Verify/Naming/FileNameBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ static string GetUniquenessParts(Namer namer, Type type)
builder.Append($".{Namer.Architecture}");
}

if (namer.UniqueForOSPlatform || VerifierSettings.SharedNamer.UniqueForOSPlatform)
{
builder.Append($".{Namer.OperatingSystemPlatform}");
}

return builder.ToString();
}
}
Expand Down
24 changes: 24 additions & 0 deletions src/Verify/Naming/Namer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,34 @@ public class Namer
internal bool UniqueForAssemblyConfiguration;
internal bool UniqueForRuntimeAndVersion;
internal bool UniqueForArchitecture;
internal bool UniqueForOSPlatform;

static Namer()
{
var (runtime, version) = GetRuntimeAndVersion();
Runtime = runtime;
RuntimeAndVersion = $"{runtime}{version.Major}_{version.Minor}";
Architecture = RuntimeInformation.ProcessArchitecture.ToString().ToLower();
OperatingSystemPlatform = GetOSPlatform();
}

static string GetOSPlatform()
{
string osPlatform;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
osPlatform = "Linux";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
osPlatform = "Windows";
}
else
{
osPlatform = "OSX";
}

return osPlatform;
}

public static string Runtime { get; }
Expand All @@ -24,6 +45,8 @@ static Namer()

public static string Architecture { get; }

public static string OperatingSystemPlatform { get; }

internal Namer()
{
}
Expand All @@ -34,6 +57,7 @@ internal Namer(Namer namer)
UniqueForAssemblyConfiguration = namer.UniqueForAssemblyConfiguration;
UniqueForRuntimeAndVersion = namer.UniqueForRuntimeAndVersion;
UniqueForArchitecture = namer.UniqueForArchitecture;
UniqueForOSPlatform = namer.UniqueForOSPlatform;
}

static (string runtime, Version Version) GetRuntimeAndVersion()
Expand Down
5 changes: 5 additions & 0 deletions src/Verify/Naming/VerifierSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,10 @@ public static void UniqueForArchitecture()
{
SharedNamer.UniqueForArchitecture = true;
}

public static void UniqueForOSPlatform()
{
SharedNamer.UniqueForOSPlatform = true;
}
}
}

0 comments on commit ef31825

Please sign in to comment.