Added customized AppendLine() for StringBuilder
This commit is contained in:
@@ -95,6 +95,7 @@ namespace AMWD.Common.AspNetCore.BasicAuthentication
|
|||||||
if (!string.IsNullOrWhiteSpace(Realm))
|
if (!string.IsNullOrWhiteSpace(Realm))
|
||||||
context.HttpContext.Response.Headers["WWW-Authenticate"] += $" realm=\"{Realm.Replace("\"", "")}\"";
|
context.HttpContext.Response.Headers["WWW-Authenticate"] += $" realm=\"{Realm.Replace("\"", "")}\"";
|
||||||
|
|
||||||
|
context.HttpContext.Response.StatusCode = 401;
|
||||||
context.Result = new UnauthorizedResult();
|
context.Result = new UnauthorizedResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|||||||
namespace AMWD.Common.Tests.Extensions
|
namespace AMWD.Common.Tests.Extensions
|
||||||
{
|
{
|
||||||
[TestClass]
|
[TestClass]
|
||||||
|
[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
|
||||||
public class StreamExtensionsTests
|
public class StreamExtensionsTests
|
||||||
{
|
{
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
|||||||
@@ -333,5 +333,21 @@ namespace AMWD.Common.Tests.Extensions
|
|||||||
Assert.IsNull(hexDecodeNull);
|
Assert.IsNull(hexDecodeNull);
|
||||||
Assert.AreEqual("", hexDecodeEmpty);
|
Assert.AreEqual("", hexDecodeEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void ShouldAddCustomLineTermination()
|
||||||
|
{
|
||||||
|
// arrange
|
||||||
|
string value = "abc";
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// act
|
||||||
|
sb.AppendLine(value, "\r");
|
||||||
|
sb.AppendLine(value, "\r");
|
||||||
|
|
||||||
|
// assert
|
||||||
|
Assert.AreEqual($"{value}\r{value}\r", sb.ToString());
|
||||||
|
Assert.IsFalse(sb.ToString().Contains('\n'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,5 +203,16 @@ namespace System
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Appends a copy of the specified string followed by the specified line terminator
|
||||||
|
/// to the end of the current <see cref="StringBuilder"/> object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sb">The <see cref="StringBuilder"/> object.</param>
|
||||||
|
/// <param name="value">The string to append.</param>
|
||||||
|
/// <param name="newLine">The line terminator.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static StringBuilder AppendLine(this StringBuilder sb, string value, string newLine)
|
||||||
|
=> sb.Append(value).Append(newLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
_nothing changed yet_
|
_nothing changed yet_
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.4.2](https://git.am-wd.de/AM.WD/common/compare/v1.4.1...v1.4.2) - 2022-05-06
|
||||||
|
### Added
|
||||||
|
- New extension for `StringBuilder` `AppendLine(value: string, newLine: string)` to add a line with a explicit defined new line character.
|
||||||
|
|
||||||
|
|
||||||
## [v1.4.1](https://git.am-wd.de/AM.WD/common/compare/v1.4.0...v1.4.1) - 2022-03-23
|
## [v1.4.1](https://git.am-wd.de/AM.WD/common/compare/v1.4.0...v1.4.1) - 2022-03-23
|
||||||
### Added
|
### Added
|
||||||
- `IntegrityHashTagHelper` can be used with `asp-integrity="true|false"` and `asp-integrity-strength="256|384|512"`
|
- `IntegrityHashTagHelper` can be used with `asp-integrity="true|false"` and `asp-integrity-strength="256|384|512"`
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
The MIT License
|
The MIT License
|
||||||
|
|
||||||
Copyright (c) 2020-2021 Andreas Müller
|
Copyright (c) 2020-2022 Andreas Müller
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
|
|||||||
Reference in New Issue
Block a user