1
0

BasicAuthentication attribute and TimeSpan.ToShortString()

- BasicAuthenticationAttribute sets the HttpContext.User property when successfully validated.
- Moved BasicAuthenticationAttribute from ActionFilter to IAsyncAuthorizationFilter.
- TimeSpan.ToShortString() is now capable of negative values.
This commit is contained in:
2022-06-23 22:51:16 +02:00
parent 97c3c303ce
commit bfe500dfa1
4 changed files with 80 additions and 39 deletions

View File

@@ -203,14 +203,17 @@ namespace AMWD.Common.Tests.Extensions
{
// arrange
var timeSpan = TimeSpan.Parse("1.10:11:12.345");
var negativeTimeSpan = TimeSpan.FromDays(-1.234);
// act
string shortString = timeSpan.ToShortString(withMilliseconds: false);
string shortStringWithMillis = timeSpan.ToShortString(withMilliseconds: true);
string shortStringNegative = negativeTimeSpan.ToShortString(withMilliseconds: true);
// assert
Assert.AreEqual("1d 10h 11m 12s", shortString);
Assert.AreEqual("1d 10h 11m 12s 345ms", shortStringWithMillis);
Assert.AreEqual("-1d 5h 36m 57s 600ms", shortStringNegative);
}
[TestMethod]