Skip to content

Instantly share code, notes, and snippets.

View jonesandy's full-sized avatar

Andy Jones jonesandy

  • London
View GitHub Profile
using Xunit.Sdk;
public class MyTestDataAttribute : DataAttribute
{
// Auto-implemented member
public override IEnumerable<object[]> GetData(MethodInfo testMethod)
{
// Create returned object arrays
yield return new object[]{ someData, someData, someData };
yield return new object[]{ someData, someData, someData };
@jonesandy
jonesandy / XUnitAsserts.cs
Last active November 9, 2024 22:22
A cheat sheet of Asserts for xUnit.net in C#
/*
STRINGS
*/
Assert.Equal(expectedString, actualString);
Assert.StartsWith(expectedString, stringToCheck);
Assert.EndsWith(expectedString, stringToCheck);
// Some can also take optional params
Assert.Equal(expectedString, actualString, ignoreCase: true);
Assert.StartsWith(expectedString, stringToCheck, StringComparison.OrdinalIgnoreCase);