Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Add tests for System.ComponentModel#12238

Merged
AlexGhiondea merged 1 commit into
dotnet:masterfrom
AlexGhiondea:AddingTestsToSystemComponentModel
Oct 5, 2016
Merged

Add tests for System.ComponentModel#12238
AlexGhiondea merged 1 commit into
dotnet:masterfrom
AlexGhiondea:AddingTestsToSystemComponentModel

Conversation

@AlexGhiondea
Copy link
Copy Markdown
Contributor

These were ported over from Mono

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

/cc @danmosemsft @weshaggard

Assert.True (ibl.SupportsChangeNotification, "7");
Assert.False (ibl.SupportsSearching, "8");
Assert.False (ibl.SupportsSorting, "9");
Assert.False (((IRaiseItemChangedEvents)l).RaisesItemChangedEvents, "10");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: instead of a number, can we use the name of the thing being tested? e.g.

Assert.True(l.AllowEdit, nameof(l.AllowEdit));

?
Same comment applies elsewhere.

Assert.True (l.RaiseListChangedEvents, "4");

Assert.False (ibl.IsSorted, "5");
Assert.Equal (ibl.SortDirection, ListSortDirection.Ascending);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: in Assert.Equal, the first arg is the expected value and the second is the actual value, so these should be swapped

Assert.True (l.RaiseListChangedEvents, "4");

Assert.False (ibl.IsSorted, "5");
Assert.Equal (ibl.SortDirection, ListSortDirection.Ascending);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on swapping the order

Assert.True (l.RaiseListChangedEvents, "4");

Assert.False (ibl.IsSorted, "5");
Assert.Equal (ibl.SortDirection, ListSortDirection.Ascending);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ditto on swapping the order

Assert.True (l.RaiseListChangedEvents, "4");

Assert.False (ibl.IsSorted, "5");
Assert.Equal (ibl.SortDirection, ListSortDirection.Ascending);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ditto on swapping the order

Assert.Null (compB.Site);
}

[Fact] // bug #522474
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same nits about bug numbers as earlier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

try {
object context = stack [-5];
Assert.False(true);
} catch (ArgumentOutOfRangeException ex) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the tests that follow this pattern should be switched to use Assert.Throws

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed all of them that did not check the caught exception.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed all of them that did not check the caught exception.

You can still do that with Assert.Throws, which returns the caught exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I didn't know about that overload! :)


result = converter.ConvertToString (null, CultureInfo.InvariantCulture,
new CultureInfo ("nl-BE"));
Assert.Equal ("nl-BE", result);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we don't actually need the local in cases like these, e.g.

Assert.Equal ("nl-BE", converter.ConvertToString(null, CultureInfo.InvariantCulture, new CultureInfo("nl-BE")));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

public override string EnglishName {
get { return "english"; }
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: things like this can be simplified with expression-bodied members, e.g.

public override string EnglishName => "english";

{
public class InstanceDescriptorTest {

private const string url = "http://www.mono-project.com/";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: consider changing

public class BindingListTest
{
[Fact]
public void BindingListDefaults ()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we cleanup the formatting to match the CoreFX coding style? Mono code style places a space before parens, which would ideally be removed here. Applies throughout.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

using System.ComponentModel.Design.Serialization;
using System.Collections.Generic;
using Xunit;
using System.Reflection;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: "Remove and Sort usings". Haven't looked at the other files, but applies to those too, if needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@@ -0,0 +1,681 @@
// Licensed to the .NET Foundation under one or more agreements.
// See the LICENSE file in the project root for more information.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Why the blank line?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to have a visual differentiator between the license header and the slightly different copyright line added.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this one more time :). Thanks for reviewing!

@AlexGhiondea AlexGhiondea force-pushed the AddingTestsToSystemComponentModel branch from 6ae2579 to 356f2fd Compare September 30, 2016 22:02
@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@dotnet-bot please test Innerloop CentOS7.1 Debug Build and Test (exit code 139)

Assert.Equal(CultureInfo.InvariantCulture, c);
}

[ActiveIssue(11611, Xunit.PlatformID.AnyUnix)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformID has been renamed TestPlatforms. It would be good if it was renamed here before merging. See #12284.

e.g. [ActiveIssue(11611, TestPlatforms.AnyUnix)]

"nl-B");
}

[ActiveIssue(11611, Xunit.PlatformID.AnyUnix)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformID has been renamed TestPlatforms. It would be good if it was renamed here before merging. See #12284.

e.g. [ActiveIssue(11611, TestPlatforms.AnyUnix)]

Assert.True(converter.CanConvertTo(typeof(InstanceDescriptor)));
}

[ActiveIssue(11611, Xunit.PlatformID.AnyUnix)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PlatformID has been renamed TestPlatforms. It would be good if it was renamed here before merging. See #12284.

e.g. [ActiveIssue(11611, TestPlatforms.AnyUnix)]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Will do!

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@dotnet-bot please test Innerloop CentOS7.1 Debug Build and Test (machine setup issue)

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@justinvp, @stephentoub let me know if you have any more feedback!

@stephentoub
Copy link
Copy Markdown
Member

Thanks, Alex. I don't need to review again.

@justinvp
Copy link
Copy Markdown
Contributor

justinvp commented Oct 4, 2016

Same here. Thanks.

@AlexGhiondea AlexGhiondea force-pushed the AddingTestsToSystemComponentModel branch 2 times, most recently from ad2dfa5 to 3b8b25a Compare October 4, 2016 23:06
@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

Argh...

@AlexGhiondea AlexGhiondea force-pushed the AddingTestsToSystemComponentModel branch from 79f7595 to 3b8b25a Compare October 5, 2016 00:02
These were ported over from Mono.
@AlexGhiondea AlexGhiondea force-pushed the AddingTestsToSystemComponentModel branch from 3b8b25a to 7564675 Compare October 5, 2016 00:03
@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@dotnet-bot please test Innerloop CentOS7.1 Release Build and Test (machine issue)

@AlexGhiondea
Copy link
Copy Markdown
Contributor Author

@dotnet-bot please test Innerloop CentOS7.1 Debug Build and Test (machine issue)

@AlexGhiondea AlexGhiondea merged commit 795777a into dotnet:master Oct 5, 2016
@AlexGhiondea AlexGhiondea deleted the AddingTestsToSystemComponentModel branch October 5, 2016 17:44
@karelz karelz modified the milestone: 1.2.0 Dec 3, 2016
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…oSystemComponentModel

Add tests for System.ComponentModel

Commit migrated from dotnet/corefx@795777a
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants