Adding assig4

This commit is contained in:
Chris
2026-04-07 20:40:02 +02:00
parent 947b34ad13
commit d10c9ab56f
12 changed files with 721 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringLibrary", "StringLibrary\StringLibrary.csproj", "{7D0147CB-B3AC-41B0-9036-9F184100C8E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringLibraryTests", "StringLibraryTests\StringLibraryTests.csproj", "{A88F10C7-9E81-4CDB-A070-77FECBEE6960}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShowCase", "ShowCase\ShowCase.csproj", "{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|x64.ActiveCfg = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|x64.Build.0 = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|x86.ActiveCfg = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Debug|x86.Build.0 = Debug|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|Any CPU.Build.0 = Release|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|x64.ActiveCfg = Release|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|x64.Build.0 = Release|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|x86.ActiveCfg = Release|Any CPU
{7D0147CB-B3AC-41B0-9036-9F184100C8E0}.Release|x86.Build.0 = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|x64.ActiveCfg = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|x64.Build.0 = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|x86.ActiveCfg = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Debug|x86.Build.0 = Debug|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|Any CPU.Build.0 = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|x64.ActiveCfg = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|x64.Build.0 = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|x86.ActiveCfg = Release|Any CPU
{A88F10C7-9E81-4CDB-A070-77FECBEE6960}.Release|x86.Build.0 = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|x64.ActiveCfg = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|x64.Build.0 = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|x86.ActiveCfg = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Debug|x86.Build.0 = Debug|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|Any CPU.Build.0 = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|x64.ActiveCfg = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|x64.Build.0 = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|x86.ActiveCfg = Release|Any CPU
{866C3C52-B1AD-4170-BCDA-22929AC2EFD0}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,36 @@
using UtilityLibraries;
int row = 0;
do
{
if (row == 0 || row >= 25)
{
ResetConsole();
}
string? input = Console.ReadLine();
if (string.IsNullOrEmpty(input))
{
break;
}
Console.WriteLine($"Input: {input} {"Begins with uppercase? ",30}: {input.StartsWithUpper()}");
Console.WriteLine();
row += 3;
}
while (true);
return;
void ResetConsole()
{
if (Console.IsOutputRedirected)
{
return;
}
Console.Clear();
Console.WriteLine("\nPress <Enter> only to exit; otherwise, enter a string and press <Enter>:\n");
row = 3;
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\StringLibrary\StringLibrary.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,14 @@
namespace UtilityLibraries;
public static class StringLibrary
{
public static bool StartsWithUpper(this string? str)
{
if (string.IsNullOrWhiteSpace(str))
{
return false;
}
return char.IsUpper(str[0]);
}
}

View File

@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>UtilityLibraries</RootNamespace>
<AssemblyName>UtilityLibraries</AssemblyName>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1 @@
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]

View File

@@ -0,0 +1,43 @@
using UtilityLibraries;
namespace StringLibraryTests;
[TestClass]
public sealed class StringLibraryTests
{
[TestMethod]
public void TestStartsWithUpper()
{
string[] words = ["Alphabet", "Zebra", "ABC", "Something", "Nothing"];
foreach (string word in words)
{
bool result = word.StartsWithUpper();
Assert.IsTrue(result, $"Expected for '{word}': true; Actual: {result}");
}
}
[TestMethod]
public void TestDoesNotStartWithUpper()
{
string[] words = ["alphabet", "zebra", "abc", "nothing", "something", "1234", ".", ";", " "];
foreach (string word in words)
{
bool result = word.StartsWithUpper();
Assert.IsFalse(result, $"Expected for '{word}': false; Actual: {result}");
}
}
[TestMethod]
public void DirectCallWithNullOrEmpty()
{
string?[] words = [string.Empty, null];
foreach (string? word in words)
{
bool result = StringLibrary.StartsWithUpper(word);
Assert.IsFalse(result, $"Expected for '{word ?? "<null>"}': false; Actual: {result}");
}
}
}

View File

@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="MSTest" Version="3.6.4" />
</ItemGroup>
<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StringLibrary\StringLibrary.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
File to test PR workflow test
Update to test update PR workflow tests
Update to test push workflow