-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unit test failed due to localized culture and line ending (#7779) #8021
Conversation
var packageStream = CreateTestPackageStreamWithDuplicateEmptyAndNonEmptyMetadataElements(); | ||
var nupkg = new PackageArchiveReader(packageStream, leaveStreamOpen: false); | ||
var nuspec = nupkg.GetNuspecReader(); | ||
|
||
useInvariantCultureAttr.Before(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use the attribute on the test method like here: https://hamidmosalla.com/2018/08/30/xunit-beforeaftertestattribute-how-to-run-code-before-and-after-test/ ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely shouldn't instantiate the attribute class directly. It already contains all necessary setup, just use [UseInvariantCulture]
attribute on appropriate test methods.
@@ -215,7 +218,7 @@ public void ThrowsWhenInvalidMinClientVersion(bool strict) | |||
|
|||
// Act & Assert | |||
var ex = Assert.Throws<ArgumentException>(() => PackageMetadata.FromNuspecReader(nuspec, strict)); | |||
Assert.Equal("'bad' is not a valid version string.\r\nParameter name: value", ex.Message); | |||
Assert.StartsWith("'bad' is not a valid version string.", ex.Message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need an additional explicit check for parameter name (that was implicit in old version): Assert.Equal("value", ex.ParamName)
here and in other cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add explicit parameter name asserts in all cases where Assert.StartsWith
was introduced and add use UseInvariantCultureAttribute
as an actual attribute.
{ | ||
private CultureInfo originalUICulture; | ||
|
||
public CultureInfo OriginalUICulture { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this is used anywhere, If not can it be removed?
Summary of the changes:
after test
3.NuGetGallery.PackagesControllerFacts+TheUploadFileActionForPostRequests.WillRejectBrokenZipFiles NuGetGallery.PackagesControllerFacts+TheUploadFileActionForPostRequests.WillShowViewWithErrorsIfPackageIdIsBreaksParsing
4.NuGetGallery.Authentication.AuthenticationServiceFacts+TheAuthenticateMethod.GivenPasswordCredential_ItThrowsArgumentException
5.NuGetGallery.Diagnostics.DiagnosticsServiceFacts+TheGetSourceMethod.RequiresNonNullOrEmptyName
6.NuGetGallery.Services.ContentServiceFacts+TheGetContentItemMethod.GivenANullOrEmptyName_ItShouldThrow
Addresses #123