Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Correcting error message when dynamic data doen't have any data
  • Loading branch information
jayaranigarg committed Dec 18, 2018
commit 740474b586cfbcd78fe0c2afd59fd2ed5d97c7a8
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public IEnumerable<object[]> GetData(MethodInfo methodInfo)
}

IEnumerable<object[]> enumerable = obj as IEnumerable<object[]>;
if (enumerable == null)

if (enumerable == null || !enumerable.Any())
{
throw new ArgumentNullException(
string.Format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ public void GetDataShouldThrowExceptionIfPropertyReturnsNull()
ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException));
}

[TestFrameworkV1.TestMethod]
public void GetDataShouldThrowExceptionIfPropertyReturnsEmpty()
{
Action action = () =>
{
var methodInfo = this.dummyTestClass.GetType().GetTypeInfo().GetDeclaredMethod("TestMethod5");
this.dynamicDataAttribute = new DynamicDataAttribute("EmptyProperty", typeof(DummyTestClass));
this.dynamicDataAttribute.GetData(methodInfo);
};

ActionUtility.ActionShouldThrowExceptionOfType(action, typeof(ArgumentNullException));
}

[TestFrameworkV1.TestMethod]
public void GetDataShouldThrowExceptionIfPropertyDoesNotReturnCorrectType()
{
Expand Down Expand Up @@ -282,7 +295,7 @@ public static IEnumerable<object[]> ReusableTestDataProperty
}

/// <summary>
/// Gets the reusable test data property.
/// Gets the null test data property.
/// </summary>
public static IEnumerable<object[]> NullProperty
{
Expand All @@ -293,7 +306,18 @@ public static IEnumerable<object[]> NullProperty
}

/// <summary>
/// Gets the reusable test data property.
/// Gets the empty test data property.
/// </summary>
public static IEnumerable<object[]> EmptyProperty
{
get
{
return new object[][] { };
}
}

/// <summary>
/// Gets the wrong test data property.
/// </summary>
public static IEnumerable<object[]> WrongDataTypeProperty
{
Expand Down Expand Up @@ -437,6 +461,15 @@ public void TestMethod4()
{
}

/// <summary>
/// The test method 5.
/// </summary>
[FrameworkV2::Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute]
[DynamicData("EmptyProperty")]
public void TestMethod5()
{
}

/// <summary>
/// DataRow test method 1.
/// </summary>
Expand Down