Adding assig4
This commit is contained in:
@@ -0,0 +1 @@
|
||||
[assembly: Parallelize(Scope = ExecutionScope.MethodLevel)]
|
||||
@@ -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}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user