-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/153650-trusts-not-returning-academies'
- Loading branch information
Showing
4 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using TramsDataApi.Extensions; | ||
using Xunit; | ||
|
||
namespace TramsDataApi.Test.Extensions | ||
{ | ||
public class StringExtensionsTests | ||
{ | ||
[Theory] | ||
[InlineData("123", 123)] | ||
[InlineData("456", 456)] | ||
[InlineData("0", 0)] | ||
[InlineData("-789", -789)] | ||
[InlineData("abc", 0)] // Invalid string | ||
[InlineData(null, 0)] // Null string | ||
[InlineData("", 0)] // Empty string | ||
public void ToInt_ReturnsExpectedResult(string input, int expectedResult) | ||
{ | ||
// Act | ||
int result = input.ToInt(); | ||
|
||
// Assert | ||
Assert.Equal(expectedResult, result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace TramsDataApi.Extensions | ||
{ | ||
public static class StringExtensions | ||
{ | ||
public static int ToInt(this string value) | ||
{ | ||
return int.TryParse(value, out var result) ? result : 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters