ソースコード
using System.Collections.Generic; using System.Linq; using NUnit.Framework; namespace Kogane { internal static class ExceptTester { public static void Test<T> ( string message, IEnumerable<T> source1, IEnumerable<T> source2 ) { var result = source1 .Except( source2 ) .ToArray() ; if ( result.Length <= 0 ) return; Assert.Fail ( $@"{message} {string.Join( "\n", result.Select( x => x.ToString() ) )}" ); } } }
使用例
ExceptTester.Test ( "【ここにメッセージ】", new[] { 1, 2, 3 }, new[] { 2, 3 } );