Skip to content

Commit b0a693b

Browse files
author
jeffshumphreys@gmail.com
committedAug 7, 2020
Major foul-up, but managed to get xUnit in place so that I can use regex tests.
1 parent f4fe370 commit b0a693b

28 files changed

+296
-452
lines changed
 

‎CharacterTransform.cs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
64
using static MySQLCLRFunctions.StringTest;
75
using static MySQLCLRFunctions._SharedConstants;
8-
6+
using static MySQLCLRFunctions.StringReduce;
97
namespace MySQLCLRFunctions
108
{
119
public static class CharacterTransform
@@ -17,8 +15,8 @@ public static string ReplaceFirstC(this string input, char replacement)
1715
//if (Char.GetUnicodeCategory(replacement) != System.Globalization.UnicodeCategory.) Warning!
1816

1917
char firstC = input.First();
20-
if (firstC != replacement) return input;
21-
return StringReduce.LTrimOne(input) + replacement;
18+
if (firstC == replacement) return input;
19+
return replacement + LTrimOne(input);
2220
}
2321

2422
public static string ReplaceLastC(this string input, char replacement)
@@ -28,8 +26,8 @@ public static string ReplaceLastC(this string input, char replacement)
2826
//if (Char.GetUnicodeCategory(replacement) != System.Globalization.UnicodeCategory.) Warning!
2927

3028
char lastC = input.Last();
31-
if (lastC != replacement) return input;
32-
return StringReduce.RTrimOne(input) + replacement;
29+
if (lastC == replacement) return input;
30+
return RTrimOne(input) + replacement;
3331
}
3432
}
3533
}

‎GlobalSuppressions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
[assembly: SuppressMessage("Usage", "RCS1246:Use element access.", Justification = "<Pending>", Scope = "member", Target = "~M:MySQLCLRFunctions.StringReduce.TrimBrackets(System.String)~System.String")]
99
[assembly: SuppressMessage("Usage", "RCS1246:Use element access.", Justification = "<Pending>", Scope = "member", Target = "~M:MySQLCLRFunctions.CharacterTransform.ReplaceFirstC(System.String,System.Char)~System.String")]
1010
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>", Scope = "type", Target = "~T:MySQLCLRFunctions._NewFunctionsToTry")]
11+
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>", Scope = "type", Target = "~T:MySQLCLRFunctions._SharedConstants")]

‎MigrationBackup/3697b4fe/MySQLCLRFunctions/NuGetUpgradeLog.html

-162
This file was deleted.

‎MigrationBackup/3697b4fe/MySQLCLRFunctions/packages.config

-4
This file was deleted.

‎MySQLCLRFunctions.csproj

+9-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<ErrorReport>prompt</ErrorReport>
2727
<WarningLevel>4</WarningLevel>
2828
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
29+
<PlatformTarget>AnyCPU</PlatformTarget>
2930
</PropertyGroup>
3031
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
3132
<DebugType>pdbonly</DebugType>
@@ -85,9 +86,6 @@
8586
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
8687
<PrivateAssets>all</PrivateAssets>
8788
</PackageReference>
88-
<PackageReference Include="NUnit">
89-
<Version>3.12.0</Version>
90-
</PackageReference>
9189
<PackageReference Include="System.Collections">
9290
<Version>4.3.0</Version>
9391
</PackageReference>
@@ -96,4 +94,12 @@
9694
<None Include=".editorconfig" />
9795
</ItemGroup>
9896
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
97+
<Choose>
98+
<When Condition="$(TargetFrameworkIdentifier) == '.NETCoreApp' And $(TargetFrameworkVersion) == 'v3.1'">
99+
<PropertyGroup>
100+
<__paket__xunit_runner_visualstudio_props>netcoreapp2.1\xunit.runner.visualstudio</__paket__xunit_runner_visualstudio_props>
101+
</PropertyGroup>
102+
</When>
103+
</Choose>
104+
<Import Project="..\..\..\..\.nuget\packages\xunit.runner.visualstudio\2.4.3\build\$(__paket__xunit_runner_visualstudio_props).props" Condition="Exists('..\..\..\..\.nuget\packages\xunit.runner.visualstudio\2.4.3\build\$(__paket__xunit_runner_visualstudio_props).props')" Label="Paket" />
99105
</Project>

‎MySQLCLRFunctions.sln

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
TestValueSettings.localuseonly = TestValueSettings.localuseonly
1616
EndProjectSection
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySQLCLRFunctionsTests", "MySQLCLRFunctionsTests\MySQLCLRFunctionsTests.csproj", "{3D1EB882-6064-4EBA-8421-1DC11A3955E9}"
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySQLCLRFunctionsTests", "MySQLCLRFunctionsTests\MySQLCLRFunctionsTests.csproj", "{83804E3C-9CBF-4071-8995-B612A38C69BE}"
1919
EndProject
2020
Global
2121
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -27,10 +27,10 @@ Global
2727
{6AEAE0BF-82E7-4793-8E9D-E649ABD0A807}.Debug|Any CPU.Build.0 = Debug|Any CPU
2828
{6AEAE0BF-82E7-4793-8E9D-E649ABD0A807}.Release|Any CPU.ActiveCfg = Release|Any CPU
2929
{6AEAE0BF-82E7-4793-8E9D-E649ABD0A807}.Release|Any CPU.Build.0 = Release|Any CPU
30-
{3D1EB882-6064-4EBA-8421-1DC11A3955E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31-
{3D1EB882-6064-4EBA-8421-1DC11A3955E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
32-
{3D1EB882-6064-4EBA-8421-1DC11A3955E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
33-
{3D1EB882-6064-4EBA-8421-1DC11A3955E9}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{83804E3C-9CBF-4071-8995-B612A38C69BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{83804E3C-9CBF-4071-8995-B612A38C69BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{83804E3C-9CBF-4071-8995-B612A38C69BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{83804E3C-9CBF-4071-8995-B612A38C69BE}.Release|Any CPU.Build.0 = Release|Any CPU
3434
EndGlobalSection
3535
GlobalSection(SolutionProperties) = preSolution
3636
HideSolutionNode = FALSE
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Xunit;
22
using MySQLCLRFunctions;
33
using System;
44
using System.Collections.Generic;
@@ -8,19 +8,26 @@
88

99
namespace MySQLCLRFunctions.Tests
1010
{
11-
[TestClass()]
1211
public class CharacterTransformTests
1312
{
14-
[TestMethod()]
13+
[Fact]
14+
[PositiveTest]
1515
public void ReplaceFirstCTest()
1616
{
17-
Assert.Fail();
17+
const string input = "Jeff Humphreys";
18+
const string validoutput = "Heff Humphreys";
19+
var output = CharacterTransform.ReplaceFirstC(input, 'H');
20+
Assert.Equal(expected: validoutput, output);
1821
}
1922

20-
[TestMethod()]
23+
[Fact]
24+
[PositiveTest]
2125
public void ReplaceLastCTest()
2226
{
23-
Assert.Fail();
27+
const string input = "Jeff Humphreys";
28+
const string validoutput = "Jeff Humphreyz";
29+
var output = CharacterTransform.ReplaceLastC(input, 'z');
30+
Assert.Equal(expected: validoutput, output);
2431
}
2532
}
2633
}

‎MySQLCLRFunctionsTests/GlobalSuppressions.cs

+4
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@
66
using System.Diagnostics.CodeAnalysis;
77

88
[assembly: SuppressMessage("Naming", "ET002:Namespace does not match file path or default namespace", Justification = "<Pending>", Scope = "namespace", Target = "~N:MySQLCLRFunctions.Tests")]
9+
[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "<Pending>", Scope = "type", Target = "~T:MySQLCLRFunctions.Tests._MyAssertFunctions")]
10+
[assembly: SuppressMessage("Style", "RCS1196:Call extension method as instance method.", Justification = "<Pending>", Scope = "member", Target = "~M:MySQLCLRFunctions.Tests.CharacterTransformTests.ReplaceFirstCTest")]
11+
[assembly: SuppressMessage("Style", "RCS1196:Call extension method as instance method.", Justification = "<Pending>", Scope = "member", Target = "~M:MySQLCLRFunctions.Tests.CharacterTransformTests.ReplaceLastCTest")]
12+
[assembly: SuppressMessage("Naming", "ET001:Type name does not match file name", Justification = "<Pending>", Scope = "type", Target = "~T:MySQLCLRFunctions.Tests.PositiveTestAttribute")]
+7-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using Xunit;
2+
using static MySQLCLRFunctions.Tests._MyAssertFunctions;
23
using MySQLCLRFunctions;
34
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using System.Text;
7-
using System.Threading.Tasks;
85

6+
// TODO: Convert to Xunit: Assert.Throws<InvalidOperationException>(() => operation()); // VS 2008
97
namespace MySQLCLRFunctions.Tests
108
{
11-
[TestClass()]
129
public class HumanizationTests
1310
{
14-
[TestMethod()]
11+
[Fact]
1512
public void HumanizeDateTimeDiffTest()
1613
{
17-
Assert.Fail();
14+
DateTime input = DateTime.Now;
15+
var output = Humanization.HumanizeDateTimeDiff(input);
16+
Assert.Matches(expectedRegexPattern: "[45] milliseconds ago", actualString: output);
1817
}
1918
}
2019
}

0 commit comments

Comments
 (0)
Please sign in to comment.