Skip to content

Commit

Permalink
Merge pull request #6 from csMACnz/release-1.1.0
Browse files Browse the repository at this point in the history
Release 1.1.0
  • Loading branch information
csMACnz committed Apr 11, 2015
2 parents 4fd1ff5 + 3467f37 commit 7fb2ad0
Show file tree
Hide file tree
Showing 41 changed files with 1,836 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ obj
*.userprefs
*.user
*.sln.DotSettings.user
*.sln.ide

# mstest test results
TestResults
Expand Down
3 changes: 2 additions & 1 deletion BCLExtensions.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
<owners>csmacnz</owners>
<licenseUrl>https://github.com/csMACnz/BCLExtensions/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/csMACnz/BCLExtensions</projectUrl>
<iconUrl>http://img.csmac.nz/BCLExtensions.net-32.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Base Class Library Extensions for C# base class library types like System.String.</description>
<summary>Base Class Library Extensions for C# base class library types like System.String.</summary>
<language>en-US</language>
<copyright>Copyright 2015</copyright>
<tags>BCLExtensions, PCL, Extensions, Extension Methods, Helpers, Base Class Library</tags>
<tags>BCLExtensions PCL Extensions Extension Methods Helpers Portable Base Class Library</tags>
</metadata>
</package>
272 changes: 15 additions & 257 deletions README.md

Large diffs are not rendered by default.

54 changes: 10 additions & 44 deletions build.tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,59 +86,25 @@ task build {
exec { msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file }
}

task appveyor-checkCoverity {
if($env:APPVEYOR_SCHEDULED_BUILD -eq "True") {
#download coverity
Invoke-WebRequest -Uri "https://scan.coverity.com/download/cxx/win_64" -Body @{ project = "$env:APPVEYOR_REPO_NAME"; token = "$env:COVERITY_TOKEN" } -OutFile "$env:APPVEYOR_BUILD_FOLDER\coverity.zip"

Expand-Archive .\coverity.zip

$script:runCoverity = $true
$script:covbuild = (Resolve-Path ".\cov-analysis-win64-*\bin\cov-build.exe").ToString()
}
}

task setup-coverity-local {
$script:runCoverity = $true
$script:covbuild = "cov-build"
$env:APPVEYOR_BUILD_FOLDER = "."
$env:APPVEYOR_BUILD_VERSION = $script:version
$env:APPVEYOR_REPO_NAME = "csmacnz/BCLExtensions"
"You should have set the COVERITY_TOKEN environment variable already"
"You should have set the COVERITY_TOKEN and COVERITY_EMAILenvironment variable already"
$env:APPVEYOR_SCHEDULED_BUILD = "True"
}

task test-coverity -depends setup-coverity-local, coverity

task coverity -precondition { return $script:runCoverity }{
& $script:covbuild --dir cov-int msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file
task coverity -precondition { return $env:APPVEYOR_SCHEDULED_BUILD -eq "True" }{
$coverityFileName = "BCLExtensions.coverity.$script:nugetVersion.zip"
Write-Zip -Path "cov-int" -OutputPath $coverityFileName
$PublishCoverity = (Resolve-Path ".\src\packages\PublishCoverity.*\PublishCoverity.exe").ToString()

& cov-build --dir cov-int msbuild "/t:Clean;Build" "/p:Configuration=$configuration" $sln_file

& $PublishCoverity compress -o $coverityFileName

#TODO an app for this:
Add-Type -AssemblyName "System.Net.Http"
$client = New-Object Net.Http.HttpClient
$client.Timeout = [TimeSpan]::FromMinutes(20)
$form = New-Object Net.Http.MultipartFormDataContent
[Net.Http.HttpContent]$formField = New-Object Net.Http.StringContent($env:COVERITY_TOKEN)
$form.Add($formField, "token")
$formField = New-Object Net.Http.StringContent($env:COVERITY_EMAIL)
$form.Add($formField, "email")
$fs = New-Object IO.FileStream("$env:APPVEYOR_BUILD_FOLDER\$coverityFileName", [IO.FileMode]::Open, [IO.FileAccess]::Read)
$formField = New-Object Net.Http.StreamContent($fs)
$form.Add($formField, "file", "$coverityFileName")
$formField = New-Object Net.Http.StringContent($script:nugetVersion)
$form.Add($formField, "version")
$formField = New-Object Net.Http.StringContent("AppVeyor scheduled build ($env:APPVEYOR_BUILD_VERSION).")
$form.Add($formField, "description")
$url = "https://scan.coverity.com/builds?project=$env:APPVEYOR_REPO_NAME"
$task = $client.PostAsync($url, $form)
try {
$task.Wait() # throws AggregateException on time-out
} catch [AggregateException] {
throw $_.Exception.InnerException
}
$task.Result
$fs.Close()
& $PublishCoverity publish -t $env:COVERITY_TOKEN -e $env:COVERITY_EMAIL -z $coverityFileName -d "AppVeyor scheduled build ($env:APPVEYOR_BUILD_VERSION)." --codeVersion $script:nugetVersion
}

task coverage -depends LocalTestSettings, build, coverage-only
Expand Down Expand Up @@ -190,4 +156,4 @@ task appveyor-install -depends GitVersion, RestoreNuGetPackages

task appveyor-build -depends build

task appveyor-test -depends AppVeyorEnvironmentSettings, postbuild, appveyor-checkCoverity, coverity
task appveyor-test -depends AppVeyorEnvironmentSettings, postbuild, coverity
20 changes: 0 additions & 20 deletions package.json

This file was deleted.

3 changes: 2 additions & 1 deletion src/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="coveralls.net" version="0.4.0" />
<package id="coveralls.net" version="0.5.0" />
<package id="OpenCover" version="4.5.3522" />
<package id="PublishCoverity" version="0.9.0" />
<package id="xunit.runners" version="1.9.2" />
</packages>
61 changes: 61 additions & 0 deletions src/BCLExtensions.Tests/ActionExtensions/AsActionUsingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using Xunit;

namespace BCLExtensions.Tests.ActionExtensions
{

public class AsActionUsingTests
{
[Fact]
public void SampleActionIsValid()
{
Assert.DoesNotThrow(() => SampleAction(42));
}

[Fact]
public void ResultNotNull()
{
Action<int> function = SampleAction;

var action = function.AsActionUsing(12);

Assert.NotNull(action);
}

private void SampleAction(int parameter)
{

}

[Fact]
public void InternalFunctionExecutes()
{
bool internalFunctionWasCalled = false;
Action<int> action = parameter =>
{
internalFunctionWasCalled = true;
};
var result = action.AsActionUsing(12);
result();

Assert.True(internalFunctionWasCalled);
}


[Fact]
public void InternalFunctionCapturesCorrectParameter()
{
const int expectedParameter = 12;
int passedParameter = 0;
Action<int> action = parameter =>
{
passedParameter = parameter;
};

var result = action.AsActionUsing(expectedParameter);
result();

Assert.Equal(expectedParameter, passedParameter);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using Xunit;

namespace BCLExtensions.Tests.ActionExtensions
{

public class AsActionUsingWithThreeParametersTests
{
[Fact]
public void SampleActionIsValid()
{
Assert.DoesNotThrow(() => SampleAction(42, "Test", true));
}

[Fact]
public void ResultNotNull()
{
Action<int, string, bool> action = SampleAction;

var result = action.AsActionUsing(12, "12", false);

Assert.NotNull(result);
}

[Fact]
public void InternalActionExecutes()
{
bool internalActionWasCalled = false;
Action<int, string, bool> action = (p1,p2,p3) =>
{
internalActionWasCalled = true;
};
var result = action.AsActionUsing(12,"24", false);
result();

Assert.True(internalActionWasCalled);
}


[Fact]
public void InternalActionCapturesCorrectParameters()
{
const int expectedParameter1 = 12;
const string expectedParameter2 = "24";
const bool expectedParameter3 = true;
int passedParameter1 = 0;
string passedParameter2 = null;
bool passedParameter3 = false;
Action<int, string, bool> action = (p1,p2,p3) =>
{
passedParameter1 = p1;
passedParameter2 = p2;
passedParameter3 = p3;
};

var result = action.AsActionUsing(expectedParameter1, expectedParameter2, expectedParameter3);
result();

Assert.Equal(expectedParameter1, passedParameter1);
Assert.Equal(expectedParameter2, passedParameter2);
Assert.Equal(expectedParameter3, passedParameter3);
}

private void SampleAction(int parameter1, string parameter2, bool parameter3)
{
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using System;
using Xunit;

namespace BCLExtensions.Tests.ActionExtensions
{

public class AsActionUsingWithTwoParametersTests
{
[Fact]
public void SampleActionIsValid()
{
Assert.DoesNotThrow(() => SampleAction(42, "Test"));
}

[Fact]
public void ResultNotNull()
{
Action<int, string> action = SampleAction;

var result = action.AsActionUsing(12, "12");

Assert.NotNull(result);
}

[Fact]
public void InternalActionExecutes()
{
bool internalActionWasCalled = false;
Action<int, string> action = (p1,p2) =>
{
internalActionWasCalled = true;
};
var result = action.AsActionUsing(12,"24");
result();

Assert.True(internalActionWasCalled);
}


[Fact]
public void InternalActionCapturesCorrectParameters()
{
const int expectedParameter1 = 12;
const string expectedParameter2 = "24";
int passedParameter1 = 0;
string passedParameter2 = null;
Action<int, string> action = (p1,p2) =>
{
passedParameter1 = p1;
passedParameter2 = p2;
};

var result = action.AsActionUsing(expectedParameter1, expectedParameter2);
result();

Assert.Equal(expectedParameter1, passedParameter1);
Assert.Equal(expectedParameter2, passedParameter2);
}

private void SampleAction(int parameter1, string parameter2)
{
}

}
}
27 changes: 25 additions & 2 deletions src/BCLExtensions.Tests/BCLExtensions.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,37 @@
<Otherwise />
</Choose>
<ItemGroup>
<Compile Include="ActionExtensions\AsActionUsingTests.cs" />
<Compile Include="ActionExtensions\AsActionUsingWithThreeParametersTests.cs" />
<Compile Include="ActionExtensions\AsActionUsingWithTwoParametersTests.cs" />
<Compile Include="ArrayExtensions\ClearTests.cs" />
<Compile Include="ArrayExtensions\OrEmptyIfNullTests.cs" />
<Compile Include="ArrayExtensions\OrNullIfEmptyTests.cs" />
<Compile Include="FuncExtensions\AsActionUsingTests - Copy.cs" />
<Compile Include="FuncExtensions\AsActionUsingWithThreeParametersTests.cs" />
<Compile Include="FuncExtensions\AsActionUsingWithTwoParametersTests.cs" />
<Compile Include="FuncExtensions\AsActionUsingTests.cs" />
<Compile Include="FuncExtensions\AsActionTests.cs" />
<Compile Include="GenericExtensions\ValueOrDefaultTests.cs" />
<Compile Include="IntExtensions\EnsureOrderTests.cs" />
<Compile Include="IntExtensions\IsBetweenExclusiveTests.cs" />
<Compile Include="IntExtensions\IsBetweenExclusiveExclusiveTests.cs" />
<Compile Include="IntExtensions\IsBetweenExclusiveInclusiveTests.cs" />
<Compile Include="IntExtensions\IsBetweenInclusiveExclusiveTests.cs" />
<Compile Include="IntExtensions\IsBetweenInclusiveInclusiveTests.cs" />
<Compile Include="IntExtensions\IsBetweenTests.cs" />
<Compile Include="StringExtensions\SafeRightTests.cs" />
<Compile Include="StringExtensions\SafeLeftTests.cs" />
<Compile Include="StringExtensions\RightTests.cs" />
<Compile Include="StringExtensions\LeftTests.cs" />
<Compile Include="StringExtensions\SafeToStringWithNullStringTests.cs" />
<Compile Include="StringExtensions\SafeTrimEndTests.cs" />
<Compile Include="StringExtensions\SafeTrimStartTests.cs" />
<Compile Include="StringExtensions\SafeTrimTests.cs" />
<Compile Include="StringExtensions\SafeToStringTests.cs" />
<Compile Include="StringExtensions\UnquotedTests.cs" />
<Compile Include="StringExtensions\ValueOrNullIfWhitespaceTests.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="TestHelpers\ArrayProvider.cs" />
<Compile Include="TestHelpers\CollectionProvider.cs" />
<Compile Include="TestHelpers\CustomICollection.cs" />
Expand Down Expand Up @@ -93,7 +117,6 @@
<Compile Include="StringExtensions\ValueOrEmptyIfNullTests.cs" />
<Compile Include="StringExtensions\ValueOrIfNullOrWhitespaceTests.cs" />
<Compile Include="StringExtensions\ValueorIfNullTests.cs" />
<Compile Include="StringExtensions\ValueOrNullIfWhitespaceTests.cs" />
<Compile Include="TestHelpers\ThrowsHelpers.cs" />
<Compile Include="TestHelperTests\CustomICollectionTests.cs" />
<Compile Include="TypeExtensions\IsOfTypeTests.cs" />
Expand Down
Loading

0 comments on commit 7fb2ad0

Please sign in to comment.