Skip to content

Instantly share code, notes, and snippets.

@JerryNixon
Last active October 18, 2023 20:06
Show Gist options
  • Select an option

  • Save JerryNixon/3df3944f856737b5cef831ab8b02641c to your computer and use it in GitHub Desktop.

Select an option

Save JerryNixon/3df3944f856737b5cef831ab8b02641c to your computer and use it in GitHub Desktop.
Using complex data types as InlineData for Xunit tests.
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace PlaygroundXunit
{
public class UnitTest1
{
[Theory]
[MemberData(nameof(Test1Data))]
public void Test1Test((string FirstName, string LastName) values)
{
Assert.NotNull(values.FirstName);
Assert.NotNull(values.LastName);
}
public static IEnumerable<object[]> Test1Data
{
get => new List<(string FirstName, string LastName)>
{
("Jerry", "Nixon"),
("Rob", "Bagby")
}.Select(x => new[] { (object)x });
}
}
}
@JerryNixon
Copy link
Author

I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment