Skip to content

Commit

Permalink
Merge pull request #17 from ottorinobruni/bug-remove-spaces
Browse files Browse the repository at this point in the history
Bug remove spaces
  • Loading branch information
ottorinobruni authored May 23, 2024
2 parents ce27d3b + 391b82b commit 7039031
Show file tree
Hide file tree
Showing 23 changed files with 531 additions and 72 deletions.
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ There are the cases currently available:
- PascalCase
- KebabCase
- SnackCase
- HashtagCase
- HashTagCase
- ConstantCase
- CobolCase
- InverseCase
- TrainCase

It's possible to count in the text:
- number of characters
Expand Down Expand Up @@ -73,8 +77,24 @@ TextCase.Convert("You talking to me?", Case.SnackCase);
"You talking to me?".ToSnackCase();
// #You #talking #to #me?
TextCase.Convert("You talking to me?", Case.HashtagCase);
"You talking to me?".ToHashtagCase();
TextCase.Convert("You talking to me?", Case.HashTagCase);
"You talking to me?".ToHashTagCase();
// YOU_TALKING_TO_ME
TextCase.Convert("You talking to me?", Case.ConstantCase);
"You talking to me?".ToConstantCase();
// YOU-TALKING-TO-ME
TextCase.Convert("You talking to me?", Case.CobolCase);
"You talking to me?".ToCobolCase();
// yOu TaLkInG tO mE?
TextCase.Convert("You talking to me?", Case.InverseCase);
"You talking to me?".ToInverseCase();
// You-Talking-To-Me
TextCase.Convert("You talking to me?", Case.TrainCase);
"You talking to me?".ToTrainCase();
// Text Count
TextCase.GetTextCount("You talking to me?");
Expand Down
2 changes: 2 additions & 0 deletions TextCase.UnitTests/CamelCaseConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class CamelCaseConverterTest
[InlineData("hello world", "helloWorld")]
[InlineData("icH bIn glückLICH", "ichBinGlücklich")]
[InlineData(" che ore sono? ", "cheOreSono?")]
[InlineData("Enter \"your text here...root = true\n\n[*.{csproj,props,targets}]\"", "enter\"YourTextHere...Root=True\n\n[*.{Csproj,Props,Targets}]\"")]
public void Convert_WhenCamelCase_TextShouldBeCamelCase(string input, string output)
{
// Setup
Expand All @@ -29,6 +30,7 @@ public void Convert_WhenCamelCase_TextShouldBeCamelCase(string input, string out
[InlineData("hello world", "helloWorld")]
[InlineData("icH bIn glückLICH", "ichBinGlücklich")]
[InlineData(" che ore sono? ", "cheOreSono?")]
[InlineData("Enter \"your text here...root = true\n\n[*.{csproj,props,targets}]\"", "enter\"YourTextHere...Root=True\n\n[*.{Csproj,Props,Targets}]\"")]
public void ToCamelCase_WhenCamelCase_TextShouldBeCamelCase(string input, string output)
{
// Execute
Expand Down
4 changes: 2 additions & 2 deletions TextCase.UnitTests/CapitaliseCaseConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public void Convert_WhenCapitaliseCase_TextShouldBeCapitaliseCase(string input,
[InlineData("Hello World", "Hello world")]
[InlineData("ICH BIN GLÜCKLICH", "Ich bin glücklich")]
[InlineData(" che ore SONO? ", "Che ore sono?")]
public void ToCapitaliseCase_WhenCapitaliseCase_TextShouldBeCapitaliseCase(string input, string output)
public void ToCapitalizeCase_WhenCapitalizeCase_TextShouldBeCapitalizeCase(string input, string output)
{
// Execute
var convertedText = input.ToCapitaliseCase();
var convertedText = input.ToCapitalizeCase();

// Assert
var expected = output;
Expand Down
8 changes: 4 additions & 4 deletions TextCase.UnitTests/CapitaliseWordsCaseConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

namespace TextCase.UnitTests
{
public class CapitaliseWordsCaseConverterTest
public class CapitalizeWordsCaseConverterTest
{
[Theory]
[InlineData("Hello World", "Hello World")]
[InlineData("ICH BIN GLÜCKLICH", "Ich Bin Glücklich")]
[InlineData(" che ore SONO? ", " Che Ore Sono? ")]
public void Convert_WhenCapitaliseCase_TextShouldBeCapitaliseCase(string input, string output)
public void Convert_WhenCapitalizeCase_TextShouldBeCapitalizeCase(string input, string output)
{
// Setup
var service = new CapitaliseWordsCaseConverter();
Expand All @@ -29,10 +29,10 @@ public void Convert_WhenCapitaliseCase_TextShouldBeCapitaliseCase(string input,
[InlineData("Hello World", "Hello World")]
[InlineData("ICH BIN GLÜCKLICH", "Ich Bin Glücklich")]
[InlineData(" che ore SONO? ", " Che Ore Sono? ")]
public void ToCapitaliseWordsCase_WhenCapitaliseCase_TextShouldBeCapitaliseCase(string input, string output)
public void ToCapitalizeWordsCase_WhenCapitalizeCase_TextShouldBeCapitalizeCase(string input, string output)
{
// Execute
var convertedText = input.ToCapitaliseWordsCase();
var convertedText = input.ToCapitalizeWordsCase();

// Assert
var expected = output;
Expand Down
56 changes: 56 additions & 0 deletions TextCase.UnitTests/CobolCaseConverterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using TextCase.Converters;
using TextCase.Extensions;
using Xunit;

namespace TextCase.UnitTests
{
public class CobolCaseConverterTest
{
[Theory]
[InlineData("hello world", "HELLO-WORLD")]
[InlineData("icH bIn glückLICH", "ICH-BIN-GLÜCKLICH")]
[InlineData("indent_style = space, 2-\nindent_size = 2", "INDENT-STYLE-SPACE-2\nINDENT-SIZE-2")]
[InlineData("Hello World!", "HELLO-WORLD")]
[InlineData("123 test", "123-TEST")]
[InlineData("test with multiple spaces", "TEST-WITH-MULTIPLE-SPACES")]
[InlineData("test_with_underscore", "TEST-WITH-UNDERSCORE")]
[InlineData("test-with-dash", "TEST-WITH-DASH")]
[InlineData("test.with.period", "TEST-WITH-PERIOD")]
[InlineData("test/with/slash", "TEST-WITH-SLASH")]
[InlineData("test\\with\\backslash", "TEST-WITH-BACKSLASH")]
public void Convert_WhenConstantCase_TextShouldBeConstantCase(string input, string expected)
{
// Setup
var service = new CobolCaseConverter();

// Execute
var actual = service.Convert(input);

// Assert
Assert.Equal(expected, actual);
}

[Theory]
[InlineData("hello world", "HELLO-WORLD")]
[InlineData("icH bIn glückLICH", "ICH-BIN-GLÜCKLICH")]
[InlineData("indent_style = space, 2-\nindent_size = 2", "INDENT-STYLE-SPACE-2\nINDENT-SIZE-2")]
[InlineData("Hello World!", "HELLO-WORLD")]
[InlineData("123 test", "123-TEST")]
[InlineData("test with multiple spaces", "TEST-WITH-MULTIPLE-SPACES")]
[InlineData("test_with_underscore", "TEST-WITH-UNDERSCORE")]
[InlineData("test-with-dash", "TEST-WITH-DASH")]
[InlineData("test.with.period", "TEST-WITH-PERIOD")]
[InlineData("test/with/slash", "TEST-WITH-SLASH")]
[InlineData("test\\with\\backslash", "TEST-WITH-BACKSLASH")]
public void ToCobolCase_WhenCobolCase_TextShouldBeCobolCase(string input, string output)
{
// Execute
var convertedText = input.ToCobolCase();

// Assert
var expected = output;
var actual = convertedText;
Assert.Equal(expected, actual);
}
}
}
56 changes: 56 additions & 0 deletions TextCase.UnitTests/ConstantCaseConverterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using TextCase.Converters;
using TextCase.Extensions;
using Xunit;

namespace TextCase.UnitTests
{
public class ConstantCaseConverterTest
{
[Theory]
[InlineData("hello world", "HELLO_WORLD")]
[InlineData("icH bIn glückLICH", "ICH_BIN_GLÜCKLICH")]
[InlineData("indent_style = space, 2-\nindent_size = 2", "INDENT_STYLE_SPACE_2\nINDENT_SIZE_2")]
[InlineData("Hello World!", "HELLO_WORLD")]
[InlineData("123 test", "123_TEST")]
[InlineData("test with multiple spaces", "TEST_WITH_MULTIPLE_SPACES")]
[InlineData("test_with_underscore", "TEST_WITH_UNDERSCORE")]
[InlineData("test-with-dash", "TEST_WITH_DASH")]
[InlineData("test.with.period", "TEST_WITH_PERIOD")]
[InlineData("test/with/slash", "TEST_WITH_SLASH")]
[InlineData("test\\with\\backslash", "TEST_WITH_BACKSLASH")]
public void Convert_WhenConstantCase_TextShouldBeConstantCase(string input, string expected)
{
// Setup
var service = new ConstantCaseConverter();

// Execute
var actual = service.Convert(input);

// Assert
Assert.Equal(expected, actual);
}

[Theory]
[InlineData("hello world", "HELLO_WORLD")]
[InlineData("icH bIn glückLICH", "ICH_BIN_GLÜCKLICH")]
[InlineData("indent_style = space, 2-\nindent_size = 2", "INDENT_STYLE_SPACE_2\nINDENT_SIZE_2")]
[InlineData("Hello World!", "HELLO_WORLD")]
[InlineData("123 test", "123_TEST")]
[InlineData("test with multiple spaces", "TEST_WITH_MULTIPLE_SPACES")]
[InlineData("test_with_underscore", "TEST_WITH_UNDERSCORE")]
[InlineData("test-with-dash", "TEST_WITH_DASH")]
[InlineData("test.with.period", "TEST_WITH_PERIOD")]
[InlineData("test/with/slash", "TEST_WITH_SLASH")]
[InlineData("test\\with\\backslash", "TEST_WITH_BACKSLASH")]
public void ToConstantCase_WhenConstantCase_TextShouldBeConstantCase(string input, string output)
{
// Execute
var convertedText = input.ToConstantCase();

// Assert
var expected = output;
var actual = convertedText;
Assert.Equal(expected, actual);
}
}
}
10 changes: 5 additions & 5 deletions TextCase.UnitTests/HashtagCaseConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

namespace TextCase.UnitTests
{
public class HashtagCaseConverterTest
public class HashTagCaseConverterTest
{
[Theory]
[InlineData("hello world", "#hello #world")]
[InlineData("icH bIn glückLICH", "#icH #bIn #glückLICH")]
[InlineData(" che ore sono? ", "#che #ore #sono?")]
public void Convert_WhenHashtagCase_TextShouldBeHashtagCase(string input, string output)
public void Convert_WhenHashTagCase_TextShouldBeHashTagCase(string input, string output)
{
// Setup
var service = new HashtagCaseConverter();
var service = new HashTagCaseConverter();

// Execute
var convertedText = service.Convert(input);
Expand All @@ -29,10 +29,10 @@ public void Convert_WhenHashtagCase_TextShouldBeHashtagCase(string input, string
[InlineData("hello world", "#hello #world")]
[InlineData("icH bIn glückLICH", "#icH #bIn #glückLICH")]
[InlineData(" che ore sono? ", "#che #ore #sono?")]
public void ToHashtagCase_WhenHashtagCase_TextShouldBeHashtagCase(string input, string output)
public void ToHashTagCase_WhenHashTagCase_TextShouldBeHashTagCase(string input, string output)
{
// Execute
var convertedText = input.ToHashtagCase();
var convertedText = input.ToHashTagCase();

// Assert
var expected = output;
Expand Down
44 changes: 44 additions & 0 deletions TextCase.UnitTests/InverseCaseConverterTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using TextCase.Converters;
using TextCase.Extensions;
using Xunit;

namespace TextCase.UnitTests
{
public class InverseCaseConverterTest
{
[Theory]
[InlineData("hello world", "hElLo WoRlD")]
[InlineData("icH bIn glückLICH", "iCh BiN gLüCkLiCh")]
[InlineData(" che ore sono? ", " cHe OrE sOnO? ")]
public void Convert_WhenCamelCase_TextShouldBeCamelCase(string input, string output)
{
// Setup
var service = new InverseCaseConverter();

// Execute
var convertedText = service.Convert(input);

// Assert
var expected = output;
var actual = convertedText;
Assert.Equal(expected, actual);
}

[Theory]
[InlineData("hello world", "hElLo WoRlD")]
[InlineData("icH bIn glückLICH", "iCh BiN gLüCkLiCh")]
[InlineData(" che ore sono? ", " cHe OrE sOnO? ")]
[InlineData("You talking to me?", "yOu TaLkInG tO mE?")]
public void ToInverseCase_WhenCamelCase_TextShouldBeCamelCase(string input, string output)
{
// Execute
var convertedText = input.ToInverseCase();

// Assert
var expected = output;
var actual = convertedText;
Assert.Equal(expected, actual);
}
}
}
7 changes: 4 additions & 3 deletions TextCase.UnitTests/KebabCaseConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ public class KebabCaseConverterTest
[Theory]
[InlineData("hello world", "hello-world")]
[InlineData("icH bIn glückLICH", "ich-bin-glücklich")]
[InlineData(" che ore sono? ", "che-ore-sono")]
[InlineData("HELLO\tWORLD", "hello-world")]
[InlineData("Hello\nWorld", "hello-world")]
[InlineData("root = true\n\n[*.{csproj,props,targets}]\nindent_style = space\nindent_size = 2", "root-true\n\n[*.{csproj,props,targets}]\nindent-style-space\nindent-size-2")]
[InlineData("indent-style-space\nindent-size-2", "indent-style-space\nindent-size-2")]
[InlineData(" che ore sono? ", "che-ore-sono?")]
[InlineData("HELLO WORLD", "hello-world")]
[InlineData(" Hello World ", "hello-world")]
[InlineData("", "")]
[InlineData(" ", "")]
Expand Down
20 changes: 20 additions & 0 deletions TextCase.UnitTests/PascalCaseConverterTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using TextCase.Converters;
using TextCase.Extensions;
using Xunit;

namespace TextCase.UnitTests
Expand Down Expand Up @@ -27,5 +28,24 @@ public void Convert_WhenPascalCase_TextShouldBePascalCase(string input, string o
var actual = convertedText;
Assert.Equal(expected, actual);
}

[Theory]
[InlineData("hello world", "HelloWorld")]
[InlineData("icH bIn glückLICH", "IchBinGlücklich")]
[InlineData(" che ore sono? ", "CheOreSono?")]
[InlineData("iPhone", "Iphone")]
[InlineData(" Hello World ", "HelloWorld")]
[InlineData("hello\tworld", "HelloWorld")]
[InlineData("Hello\nWorld", "HelloWorld")]
public void ToPascalCase_WhenUpperCase_TextShouldBePascalCase(string input, string output)
{
// Execute
var convertedText = input.ToPascalCase();

// Assert
var expected = output;
var actual = convertedText;
Assert.Equal(expected, actual);
}
}
}
47 changes: 21 additions & 26 deletions TextCase.UnitTests/TextCase.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\TextCase\TextCase.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TextCase\TextCase.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit 7039031

Please sign in to comment.