Skip to content

Commit a508a76

Browse files
committed
Initial Commit. .NET 4.0 and 4.5 versions
I wrote all of these methods over the past few years. Some of it is borrowed code.
1 parent 07fdede commit a508a76

38 files changed

+3014
-0
lines changed

Helpers.Net.4.0.sln

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers.Net.4.0", "Src\Helpers.Net\Helpers.Net.4.0.csproj", "{B3366823-F879-4914-A016-DCE1360F45DC}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers.Net.Tests.4.0", "Src\Helpers.Net.Tests\Helpers.Net.Tests.4.0.csproj", "{2C910077-C8EB-4AFE-9778-151182374A34}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
Stage|Any CPU = Stage|Any CPU
15+
Stage|x64 = Stage|x64
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|x64.ActiveCfg = Debug|x64
21+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|x64.Build.0 = Debug|x64
22+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|Any CPU.Build.0 = Release|Any CPU
24+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|x64.ActiveCfg = Release|x64
25+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|x64.Build.0 = Release|x64
26+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|Any CPU.ActiveCfg = Stage|Any CPU
27+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|Any CPU.Build.0 = Stage|Any CPU
28+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|x64.ActiveCfg = Stage|x64
29+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|x64.Build.0 = Stage|x64
30+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|x64.ActiveCfg = Debug|Any CPU
33+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
34+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|Any CPU.Build.0 = Release|Any CPU
35+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|x64.ActiveCfg = Release|Any CPU
36+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|Any CPU.ActiveCfg = Release|Any CPU
37+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|Any CPU.Build.0 = Release|Any CPU
38+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|x64.ActiveCfg = Release|Any CPU
39+
EndGlobalSection
40+
GlobalSection(SolutionProperties) = preSolution
41+
HideSolutionNode = FALSE
42+
EndGlobalSection
43+
EndGlobal

Helpers.Net.4.0.suo

23.5 KB
Binary file not shown.

Helpers.Net.4.5.sln

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2012
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers.Net.Tests.4.5", "Src\Helpers.Net.Tests\Helpers.Net.Tests.4.5.csproj", "{2C910077-C8EB-4AFE-9778-151182374A34}"
5+
EndProject
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Helpers.Net.4.5", "Src\Helpers.Net\Helpers.Net.4.5.csproj", "{B3366823-F879-4914-A016-DCE1360F45DC}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Release|Any CPU = Release|Any CPU
13+
Release|x64 = Release|x64
14+
Stage|Any CPU = Stage|Any CPU
15+
Stage|x64 = Stage|x64
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{2C910077-C8EB-4AFE-9778-151182374A34}.Debug|x64.ActiveCfg = Debug|Any CPU
21+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{2C910077-C8EB-4AFE-9778-151182374A34}.Release|x64.ActiveCfg = Release|Any CPU
24+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|Any CPU.ActiveCfg = Release|Any CPU
25+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|Any CPU.Build.0 = Release|Any CPU
26+
{2C910077-C8EB-4AFE-9778-151182374A34}.Stage|x64.ActiveCfg = Release|Any CPU
27+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
28+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
29+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|x64.ActiveCfg = Debug|x64
30+
{B3366823-F879-4914-A016-DCE1360F45DC}.Debug|x64.Build.0 = Debug|x64
31+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|x64.ActiveCfg = Release|x64
34+
{B3366823-F879-4914-A016-DCE1360F45DC}.Release|x64.Build.0 = Release|x64
35+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|Any CPU.ActiveCfg = Stage|Any CPU
36+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|Any CPU.Build.0 = Stage|Any CPU
37+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|x64.ActiveCfg = Stage|x64
38+
{B3366823-F879-4914-A016-DCE1360F45DC}.Stage|x64.Build.0 = Stage|x64
39+
EndGlobalSection
40+
GlobalSection(SolutionProperties) = preSolution
41+
HideSolutionNode = FALSE
42+
EndGlobalSection
43+
EndGlobal

Helpers.Net.4.5.v11.suo

70.5 KB
Binary file not shown.

Src/Helpers.Net.Tests/AlphaIDTests.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
using System.Text.RegularExpressions;
7+
8+
namespace HelperMethodsTests
9+
{
10+
/// <summary>
11+
/// Summary description for AlphaIDTests
12+
/// </summary>
13+
[TestClass]
14+
public class AlphaIDTests
15+
{
16+
public AlphaIDTests()
17+
{ }
18+
19+
private TestContext testContextInstance;
20+
21+
/// <summary>
22+
///Gets or sets the test context which provides
23+
///information about and functionality for the current test run.
24+
///</summary>
25+
public TestContext TestContext
26+
{
27+
get
28+
{
29+
return testContextInstance;
30+
}
31+
set
32+
{
33+
testContextInstance = value;
34+
}
35+
}
36+
37+
#region Additional test attributes
38+
//
39+
// You can use the following additional attributes as you write your tests:
40+
//
41+
// Use ClassInitialize to run code before running the first test in the class
42+
// [ClassInitialize()]
43+
// public static void MyClassInitialize(TestContext testContext) { }
44+
//
45+
// Use ClassCleanup to run code after all tests in a class have run
46+
// [ClassCleanup()]
47+
// public static void MyClassCleanup() { }
48+
//
49+
// Use TestInitialize to run code before running each test
50+
// [TestInitialize()]
51+
// public void MyTestInitialize() { }
52+
//
53+
// Use TestCleanup to run code after each test has run
54+
// [TestCleanup()]
55+
// public void MyTestCleanup() { }
56+
//
57+
#endregion
58+
59+
[TestMethod]
60+
public void AlphaNumericString()
61+
{
62+
Assert.IsTrue(Regex.IsMatch(new Random().AlphaNumericString(), @"^\w{5}$"));
63+
}
64+
}
65+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using Microsoft.VisualStudio.TestTools.UnitTesting;
6+
7+
namespace HelperMethodsTests
8+
{
9+
[TestClass]
10+
public class DateTimeExtensionsTests
11+
{
12+
[TestMethod]
13+
public void ElapsedStringTest()
14+
{
15+
Assert.AreEqual("0 seconds", DateTime.Now.Elapsed().ToElapsedString());
16+
Assert.AreEqual("1 second", DateTime.Now.Subtract(new TimeSpan(0, 0, 1)).Elapsed().ToElapsedString());
17+
Assert.AreEqual("1 hour", DateTime.Now.Subtract(new TimeSpan(1, 1, 0)).Elapsed().ToElapsedString());
18+
Assert.AreEqual("2 hours", DateTime.Now.Subtract(new TimeSpan(2, 0, 0)).Elapsed().ToElapsedString());
19+
Assert.AreEqual("5 days", DateTime.Now.Subtract(new TimeSpan(5, 1, 0, 0)).Elapsed().ToElapsedString());
20+
Assert.AreEqual("6 months", DateTime.Now.Subtract(new TimeSpan(30 * 6, 1, 1, 1)).Elapsed().ToElapsedString());
21+
Assert.AreEqual("1 year", DateTime.Now.Subtract(new TimeSpan(365, 1, 1, 1, 1)).Elapsed().ToElapsedString());
22+
Assert.AreEqual("5 years", DateTime.Now.Subtract(new TimeSpan(5 * 365, 0, 0, 0)).Elapsed().ToElapsedString());
23+
}
24+
}
25+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{2C910077-C8EB-4AFE-9778-151182374A34}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>HelperMethodsTests</RootNamespace>
12+
<AssemblyName>HelperMethodsTests</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16+
<FileUpgradeFlags>
17+
</FileUpgradeFlags>
18+
<UpgradeBackupLocation>
19+
</UpgradeBackupLocation>
20+
<OldToolsVersion>3.5</OldToolsVersion>
21+
</PropertyGroup>
22+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
23+
<DebugSymbols>true</DebugSymbols>
24+
<DebugType>full</DebugType>
25+
<Optimize>false</Optimize>
26+
<OutputPath>bin\Debug\</OutputPath>
27+
<DefineConstants>DEBUG;TRACE</DefineConstants>
28+
<ErrorReport>prompt</ErrorReport>
29+
<WarningLevel>4</WarningLevel>
30+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
31+
</PropertyGroup>
32+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
33+
<DebugType>pdbonly</DebugType>
34+
<Optimize>true</Optimize>
35+
<OutputPath>bin\Release\</OutputPath>
36+
<DefineConstants>TRACE</DefineConstants>
37+
<ErrorReport>prompt</ErrorReport>
38+
<WarningLevel>4</WarningLevel>
39+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
40+
</PropertyGroup>
41+
<ItemGroup>
42+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
43+
<Reference Include="System" />
44+
<Reference Include="System.Core">
45+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
46+
</Reference>
47+
<Reference Include="System.Data" />
48+
<Reference Include="System.Xml" />
49+
</ItemGroup>
50+
<ItemGroup>
51+
<Compile Include="AlphaIDTests.cs" />
52+
<Compile Include="DateTimeExtensionsTests.cs" />
53+
<Compile Include="StringParserTests.cs" />
54+
<Compile Include="LinqExtensionsTests.cs" />
55+
<Compile Include="ParallelProcessorTests.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
<Compile Include="StringExtensionTests.cs" />
58+
<Compile Include="StringHtmlExtensionTests.cs" />
59+
</ItemGroup>
60+
<ItemGroup>
61+
<ProjectReference Include="..\Helpers.Net\Helpers.Net.4.0.csproj">
62+
<Project>{B3366823-F879-4914-A016-DCE1360F45DC}</Project>
63+
<Name>Helpers.Net.4.0</Name>
64+
</ProjectReference>
65+
</ItemGroup>
66+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
67+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
68+
Other similar extension points exist, see Microsoft.Common.targets.
69+
<Target Name="BeforeBuild">
70+
</Target>
71+
<Target Name="AfterBuild">
72+
</Target>
73+
-->
74+
</Project>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>9.0.30729</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{2C910077-C8EB-4AFE-9778-151182374A34}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>HelperMethodsTests</RootNamespace>
12+
<AssemblyName>HelperMethodsTests</AssemblyName>
13+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16+
<FileUpgradeFlags>
17+
</FileUpgradeFlags>
18+
<UpgradeBackupLocation>
19+
</UpgradeBackupLocation>
20+
<OldToolsVersion>3.5</OldToolsVersion>
21+
<TargetFrameworkProfile />
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
24+
<DebugSymbols>true</DebugSymbols>
25+
<DebugType>full</DebugType>
26+
<Optimize>false</Optimize>
27+
<OutputPath>bin\Debug\</OutputPath>
28+
<DefineConstants>DEBUG;TRACE</DefineConstants>
29+
<ErrorReport>prompt</ErrorReport>
30+
<WarningLevel>4</WarningLevel>
31+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
32+
<Prefer32Bit>false</Prefer32Bit>
33+
</PropertyGroup>
34+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
35+
<DebugType>pdbonly</DebugType>
36+
<Optimize>true</Optimize>
37+
<OutputPath>bin\Release\</OutputPath>
38+
<DefineConstants>TRACE</DefineConstants>
39+
<ErrorReport>prompt</ErrorReport>
40+
<WarningLevel>4</WarningLevel>
41+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
42+
<Prefer32Bit>false</Prefer32Bit>
43+
</PropertyGroup>
44+
<ItemGroup>
45+
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
46+
<Reference Include="System" />
47+
<Reference Include="System.Core">
48+
<RequiredTargetFramework>3.5</RequiredTargetFramework>
49+
</Reference>
50+
<Reference Include="System.Data" />
51+
<Reference Include="System.Xml" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<Compile Include="AlphaIDTests.cs" />
55+
<Compile Include="DateTimeExtensionsTests.cs" />
56+
<Compile Include="StringParserTests.cs" />
57+
<Compile Include="LinqExtensionsTests.cs" />
58+
<Compile Include="ParallelProcessorTests.cs" />
59+
<Compile Include="Properties\AssemblyInfo.cs" />
60+
<Compile Include="StringExtensionTests.cs" />
61+
<Compile Include="StringHtmlExtensionTests.cs" />
62+
</ItemGroup>
63+
<ItemGroup>
64+
<ProjectReference Include="..\Helpers.Net\Helpers.Net.4.5.csproj">
65+
<Project>{b3366823-f879-4914-a016-dce1360f45dc}</Project>
66+
<Name>Helpers.Net.4.5</Name>
67+
</ProjectReference>
68+
</ItemGroup>
69+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
70+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
71+
Other similar extension points exist, see Microsoft.Common.targets.
72+
<Target Name="BeforeBuild">
73+
</Target>
74+
<Target Name="AfterBuild">
75+
</Target>
76+
-->
77+
</Project>

0 commit comments

Comments
 (0)