Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,9 @@ dotnet_diagnostic.CA1505.severity = none
# ApiPaginationAttribute.OnActionExecuting always constructs the object and overwrites the action argument
[web/Models/ApiPagination.cs]
dotnet_diagnostic.S6964.severity = none

# S6964: IsOther is bound as part of the save request but never trusted — ValidateSelectionAsync
# re-reads it from the option table before the mapper consumes it, so a client value cannot
# influence what is stored
[web/Areas/Students/Models/CareerDropdownOption.cs]
dotnet_diagnostic.S6964.severity = none
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,9 @@ web/Areas/Effort/Scripts/Effort_Database_Schema_And_Data_LEGACY.txt
# PhoneLists migration script outputs
web/Areas/Personnel/Scripts/AnalysisOutput/

# Career Selection migration script outputs
web/Areas/Students/Scripts/AnalysisOutput/

# Code-quality tool outputs (fallow cache + jscpd + ReSharper reports)
.fallow/
VueApp/.fallow/
Expand Down
4 changes: 3 additions & 1 deletion .jscpd.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"**/coverage/**",
"**/bin/**",
"**/obj/**",
"**/Effort/Scripts/**"
"**/Effort/Scripts/**",
Comment thread
bniedzie marked this conversation as resolved.
Resolved
"**/Personnel/Scripts/**",
"**/Students/Scripts/**"
],
"ignorePattern": [
"^\\s*import\\s+.*from\\s+['\"][^'\"]+['\"]\\s*;?\\s*$"
Expand Down
26 changes: 26 additions & 0 deletions test/Classes/Utilities/DbUpdateExceptionExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,30 @@ public void IsDataRejection_IsFalse_WhenTheInnerExceptionIsNotFromSqlServer()

Assert.False(ex.IsDataRejection());
}

[Theory]
[InlineData(2601)] // duplicate key in a unique index
[InlineData(2627)] // unique or primary key constraint violation
public void IsUniqueKeyViolationNumber_IsTrue_ForUniqueKeyErrors(int number)
{
Assert.True(DbUpdateExceptionExtensions.IsUniqueKeyViolationNumber(number));
}

[Theory]
[InlineData(547)] // foreign key - a retry against the winning row would fail the same way
[InlineData(8152)] // truncation - likewise
[InlineData(2628)]
[InlineData(1205)]
public void IsUniqueKeyViolationNumber_IsFalse_ForOtherErrors(int number)
{
Assert.False(DbUpdateExceptionExtensions.IsUniqueKeyViolationNumber(number));
}

[Fact]
public void IsUniqueKeyViolation_IsFalse_WhenTheInnerExceptionIsNotFromSqlServer()
{
var ex = new DbUpdateException("Something failed", new TimeoutException("The wait expired"));

Assert.False(ex.IsUniqueKeyViolation());
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Viper.Classes.Utilities;

namespace Viper.test.Effort;
namespace Viper.test.Classes.Utilities;

/// <summary>
/// Unit tests for ExcelHelper utility methods.
Expand Down Expand Up @@ -33,6 +33,29 @@ public void SanitizeStringCell_PrefixesAtSign()
Assert.Equal("'@SUM", ExcelHelper.SanitizeStringCell("@SUM"));
}

[Theory]
Comment thread
rlorenzo marked this conversation as resolved.
Resolved
[InlineData("\t=SUM(A1)")]
[InlineData("\r=SUM(A1)")]
[InlineData("\n+cmd")]
[InlineData("\r\n-calculation")]
[InlineData(" @SUM")]
[InlineData(" \t\r\n=HYPERLINK(\"x\")")]
public void SanitizeStringCell_PrefixesFormulaBehindLeadingWhitespace(string value)
{
Assert.Equal("'" + value, ExcelHelper.SanitizeStringCell(value));
}

[Theory]
[InlineData(" Normal text")]
[InlineData("\tIndented")]
[InlineData("\r\nSecond line")]
[InlineData(" ")]
[InlineData("Ends with =")]
public void SanitizeStringCell_LeavesNonFormulaTextUnchanged(string value)
{
Assert.Equal(value, ExcelHelper.SanitizeStringCell(value));
}

[Fact]
public void SanitizeStringCell_LeavesNormalTextUnchanged()
{
Expand Down
Loading
Loading