-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add initial tests to System.Data.DataSetExtensions #22892
Conversation
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.
Two of the files can probably be reverted. Other than that it looks good.
{ | ||
[Fact] | ||
public void AsEnumerable_NullSource_ThrowsArgumentNullException() | ||
public void Where_ThrowsArgumentNull() |
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.
The tests in here look to be the same as what @hughbe added, just ordered differently. You should be able to revert this file.
public class DataTableExtensionsTests | ||
{ | ||
|
||
[Fact] |
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.
This also looks like it is just split out differently.
@@ -0,0 +1,279 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. | |||
// The .NET Foundation licenses this file to you under the MIT license. |
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 believe for files originating from Mono, we need to exclude this 2nd line of the standard header (but keep the 1st and 3rd). @JeremyKuhne can confirm.
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.
That is correct- sorry, missed that.
{ | ||
DataRowComparer<DataRow> c1 = DataRowComparer.Default; | ||
DataRowComparer<DataRow> c2 = DataRowComparer.Default; | ||
Assert.Equal(c1, c2); |
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.
Do we expect these to just be equal or to actually be the same exact object? If the latter, we can tighten this assert by using Assert.Same instead of Assert.Equal.
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.
Yes, this should be Assert.Same
// LAMESPEC: .NET fails here | ||
DataRow r3 = dt.Rows.Add (new object [] {"foo", "baz"}); | ||
Assert.IsFalse (c.GetHashCode (r1) == c.GetHashCode (r3), "#4"); | ||
*/ |
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 we delete commented out regions like this?
Assert.Null(ex.InnerException); | ||
// #4 | ||
Assert.NotNull(ex.Message); | ||
// #5 |
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.
What's the value of these "// #somenumber" comments?
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.
Didn't want to change much from the Mono source, presumably this was in their sources?
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.
They were using NUnit before and the commands looked like...
Assert.IsNull(ex.InnerException, "#3") for example.
I can delete the comments if we think they are unnecessary
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.
They're unnecessary as comments. The value of having them as strings in the assert call is that they'd be traced out as part of a failing assert, so you could search for that string and find the failing line, but as comments, they don't serve that purpose.
|
||
[Fact] | ||
// no error for empty table this time. | ||
// [Category("NotWorking")] // some DataTableReader internal issues |
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 we delete comments like this?
// Assert.Equal(1, dv[0]["ID"]); | ||
// // #2 | ||
// Assert.Equal(4, dv[1]["ID"]); | ||
//} |
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.
Is this commented out because the APIs it needs don't exist? If so, can we just delete it? Or if we expect to add the APIs, could we tag this with a TODO and associated issue number?
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.
Sorry, I missed this. AsDataView is one of the APIs that no longer exists on this library due to reliance on InternalsVisibleTo, so for now I'll remove it.
select new { | ||
StudentID = line.Field<int> ("ID"), | ||
StudentName = line.Field<string> ("Name"), | ||
StudentScore = line.Field<int> ("Score") }; |
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.
Nit: the whole query should be indented
Assert.True(false, "should match only one raw"); | ||
// #1 | ||
Assert.Equal(100, ql.StudentScore); | ||
iterated = true; |
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.
Nit: the body of the foreach should be indented. The brace after the foreach should also be on its own line.
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.
Thanks for adding all of these.
XML will automatically compile when moved to right location that is in the project, not on local desktop. Add tests for TypedTableBaseExtensions and EnumerableRowCollectionExtensions
Reverted files back to originals
@nchikanov when you are ready, you can invoke @stephentoub for a final review. |
@nchikanov if you like you can check code coverage (instructions) to see whether your tests miss anything interesting. |
@danmosemsft Read my mind! Just sent Stephen a Skype message about this beforehand. I'll take a look tomorrow 👍 |
Basically, instead of doing:
to run the tests, add
The resulting coverage report will be available in bin\tests\coverage\index.htm. |
😄 |
So tests can find doc
@dotnet-bot test Linux x64 Release Build |
test Linux x64 Release Build |
1 similar comment
test Linux x64 Release Build |
@stephentoub I think we're ready for final review 😄 |
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.
Thanks :)
* Add tests from mono and more to existing tests * Clean up tests for Mono * Fix up some tests, add necessary XML file * Add more tests, add XML to correct location XML will automatically compile when moved to right location that is in the project, not on local desktop. Add tests for TypedTableBaseExtensions and EnumerableRowCollectionExtensions * Fix path of testdataset1.xml So tests can find doc Commit migrated from dotnet/corefx@73f62d0
Integrated new tests as well as existing tests from Mono.
Still going through and adding tests, this is initial PR.
Re: #22803