Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Thecentury authored May 6, 2018
2 parents e0cc765 + f6f3209 commit 8563e6a
Show file tree
Hide file tree
Showing 28 changed files with 333 additions and 130 deletions.
19 changes: 19 additions & 0 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
trigger:
- master
- rel/*

queue: Hosted VS2017
variables:
BuildConfiguration: Release
steps:
- template: .vsts-shared.yml
parameters:
signSteps:
- task: PowerShell@2
displayName: Authenticode Sign artifacts
inputs:
filePath: scripts/Sign-Package.ps1
env:
SignClientUser: $(SignClientUser)
SignClientSecret: $(SignClientSecret)
ArtifactDirectory: $(Build.ArtifactStagingDirectory)\Packages
5 changes: 5 additions & 0 deletions .vsts-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
queue: Hosted VS2017
variables:
BuildConfiguration: Release
steps:
- template: .vsts-shared.yml
63 changes: 63 additions & 0 deletions .vsts-shared.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
parameters:
signSteps: []

steps:
- task: BatchScript@1
inputs:
filename: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Enterprise\\Common7\\Tools\\VsDevCmd.bat"
arguments: -no_logo
modifyEnvironment: true
displayName: Setup Environment Variables

- task: NuGetToolInstaller@0
displayName: Use NuGet 4.6.2
inputs:
versionSpec: 4.6.2

- task: DotNetCoreCLI@2
inputs:
command: build
projects: scripts/setversion.csproj
arguments: -c $(BuildConfiguration)
displayName: Set Version
condition: eq(variables['system.pullrequest.isfork'], false)

- powershell: |
mkdir $(Build.ArtifactStagingDirectory)\Logs
mkdir $(Build.ArtifactStagingDirectory)\Packages
msbuild .\src\Humanizer.sln /restore /m /bl:$(Build.ArtifactStagingDirectory)\Logs\restore.binlog /p:Configuration=$(BuildConfiguration)
displayName: Build

- powershell: |
# version
nuget install NerdBank.GitVersioning -SolutionDir $(Build.SourcesDirectory) -Verbosity quiet -ExcludeVersion
$vers = & $(Build.SourcesDirectory)\packages\nerdbank.gitversioning\tools\Get-Version.ps1
$nugetVer = $vers.NuGetPackageVersion
ls .\NuSpecs\*.nuspec | %{ nuget pack $_.FullName -version "$nugetVer" -BasePath "src" -NoPackageAnalysis -OutputDirectory $(Build.ArtifactStagingDirectory)\Packages }
displayName: Create packages

- task: DotNetCoreCLI@2
inputs:
command: test
projects: .\src\Humanizer.Tests\Humanizer.Tests.csproj
arguments: -c $(BuildConfiguration)
displayName: Run Tests

- ${{ parameters.signSteps }}

- task: PublishBuildArtifacts@1
displayName: Publish Package Artifacts
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)\Packages
artifactType: container
artifactName: Packages
condition: eq(variables['system.pullrequest.isfork'], false)

- task: PublishBuildArtifacts@1
displayName: Publish Log Artifacts
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)\Logs
artifactType: container
artifactName: Logs
condition: eq(variables['system.pullrequest.isfork'], false)
57 changes: 0 additions & 57 deletions appveyor.yml

This file was deleted.

4 changes: 3 additions & 1 deletion scripts/Sign-Package.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ if([string]::IsNullOrEmpty($env:SignClientSecret)){
return;
}

& nuget install SignClient -Version 0.9.1 -SolutionDir "$currentDirectory\..\" -Verbosity quiet -ExcludeVersion

# Setup Variables we need to pass into the sign client tool

$appSettings = "$currentDirectory\SignClient.json"

$appPath = "$currentDirectory\..\packages\SignClient\tools\netcoreapp2.0\SignClient.dll"

$nupgks = ls $currentDirectory\..\*.nupkg | Select -ExpandProperty FullName
$nupgks = gci $Env:ArtifactDirectory\*.nupkg | Select -ExpandProperty FullName

foreach ($nupkg in $nupgks){
Write-Host "Submitting $nupkg for signing"
Expand Down
11 changes: 11 additions & 0 deletions scripts/setversion.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions scripts/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"inherit": true,
"cloudBuild": {
"buildNumber": {
"enabled": true
}
}
}
20 changes: 3 additions & 17 deletions src/Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.7" PrivateAssets="all" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.6.0" PrivateAssets="All" />
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.0" PrivateAssets="All" />
</ItemGroup>

<!-- https://github.com/NuGet/Home/issues/4337 -->

<PropertyGroup>
<NerdbankGitVersioningVersion>2.1.7</NerdbankGitVersioningVersion>
</PropertyGroup>

<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' == 'true' ">
<Import Project="$(NuGetPackageRoot)nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets"
Condition="Exists('$(NuGetPackageRoot)nerdbank.gitversioning\$(NerdbankGitVersioningVersion)\buildCrossTargeting\Nerdbank.GitVersioning.targets')" />
</ImportGroup>
<Target Name="FixUpVersion"
BeforeTargets="_GenerateRestoreProjectSpec"
DependsOnTargets="GetBuildVersion"
Condition=" '$(NerdbankGitVersioningTasksPath)' != '' " />

</Project>
8 changes: 7 additions & 1 deletion src/Humanizer.Tests.Shared/BitFieldEnumHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Humanizer.Tests
{
[UseCulture("en")]
public class BitFieldEnumHumanizeTests
public class BitFieldEnumHumanizeTests
{
[Fact]
public void CanHumanizeSingleWordDescriptionAttribute()
Expand Down Expand Up @@ -47,5 +47,11 @@ public void CanHumanizeShortMultipleValueBitFieldEnum()
var xoredBitFlag = (ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY);
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize());
}

[Fact]
public void CanHumanizeBitFieldEnumWithZeroValue()
{
Assert.Equal(BitFlagEnumTestsResources.None, BitFieldEnumUnderTest.NONE.Humanize());
}
}
}
11 changes: 7 additions & 4 deletions src/Humanizer.Tests.Shared/BitFieldEnumUnderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,26 @@ namespace Humanizer.Tests
[Flags]
public enum BitFieldEnumUnderTest : int
{
[Display( Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)]
[Display(Description = BitFlagEnumTestsResources.None)]
NONE = 0,
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)]
RED = 1,
[Display( Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)]
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)]
DARK_GRAY = 2
}

[Flags]
public enum ShortBitFieldEnumUnderTest : short
{
[Display( Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)]
[Display(Description = BitFlagEnumTestsResources.MemberWithSingleWordDisplayAttribute)]
RED = 1,
[Display( Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)]
[Display(Description = BitFlagEnumTestsResources.MemberWithMultipleWordDisplayAttribute)]
DARK_GRAY = 2
}

public class BitFlagEnumTestsResources
{
public const string None = "None";
public const string MemberWithSingleWordDisplayAttribute = "Red";
public const string MemberWithMultipleWordDisplayAttribute = "Dark Gray";

Expand Down
40 changes: 33 additions & 7 deletions src/Humanizer.Tests.Shared/CollectionHumanizeTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using Xunit;

Expand All @@ -15,7 +15,7 @@ public override string ToString()
}

[UseCulture("en")]
public class CollectionHumanizeTests
public class CollectionHumanizeTests
{
[Fact]
public void HumanizeReturnsOnlyNameWhenCollectionContainsOneItem()
Expand Down Expand Up @@ -76,37 +76,63 @@ public void HumanizeDefaultsToToString()
}

[Fact]
public void HumanizeUsesObjectFormatter()
public void HumanizeUsesStringDisplayFormatter()
{
var humanized = _testCollection.Humanize(sc => string.Format("SomeObject #{0} - {1}", sc.SomeInt, sc.SomeString));
Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, and SomeObject #3 - Three", humanized);
}

[Fact]
public void HumanizeUsesObjectFormatterWhenSeparatorIsProvided()
public void HumanizeUsesObjectDisplayFormatter()
{
var humanized = _testCollection.Humanize(sc => sc.SomeInt);
Assert.Equal("1, 2, and 3", humanized);
}

[Fact]
public void HumanizeUsesStringDisplayFormatterWhenSeparatorIsProvided()
{
var humanized = _testCollection.Humanize(sc => string.Format("SomeObject #{0} - {1}", sc.SomeInt, sc.SomeString), "or");
Assert.Equal("SomeObject #1 - One, SomeObject #2 - Two, or SomeObject #3 - Three", humanized);
}

[Fact]
public void HumanizeUsesObjectDisplayFormatterWhenSeparatorIsProvided()
{
var humanized = _testCollection.Humanize(sc => sc.SomeInt, "or");
Assert.Equal("1, 2, or 3", humanized);
}

[Fact]
public void HumanizeHandlesNullItemsWithoutAnException()
{
Assert.Null(Record.Exception(() => new object[] { null, null }.Humanize()));
}

[Fact]
public void HumanizeHandlesNullFormatterReturnsWithoutAnException()
public void HumanizeHandlesNullStringDisplayFormatterReturnsWithoutAnException()
{
Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => null)));
Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => (string)null)));
}

[Fact]
public void HumanizeRunsFormatterOnNulls()
public void HumanizeHandlesNullObjectDisplayFormatterReturnsWithoutAnException()
{
Assert.Null(Record.Exception(() => new[] { "A", "B", "C" }.Humanize(_ => (object)null)));
}

[Fact]
public void HumanizeRunsStringDisplayFormatterOnNulls()
{
Assert.Equal("1, (null), and 3", new int?[] { 1, null, 3 }.Humanize(_ => _?.ToString() ?? "(null)"));
}

[Fact]
public void HumanizeRunsObjectDisplayFormatterOnNulls()
{
Assert.Equal("1, 2, and 3", new int?[] { 1, null, 3 }.Humanize(_ => _ ?? 2));
}

[Fact]
public void HumanizeRemovesEmptyItemsByDefault()
{
Expand Down
Loading

0 comments on commit 8563e6a

Please sign in to comment.