forked from bUnit-dev/bUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiffAssertExtensionsTest.cs
72 lines (62 loc) · 1.83 KB
/
DiffAssertExtensionsTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Collections.Generic;
using AngleSharp.Diffing.Core;
using Moq;
using Shouldly;
using Xunit;
using Xunit.Sdk;
namespace Bunit
{
public class DiffAssertExtensionsTest
{
[Fact(DisplayName = "ShouldHaveSingleChange throws when input is null")]
public void Test001()
{
IReadOnlyList<IDiff>? diffs = null;
Exception? exception = null;
try
{
DiffAssertExtensions.ShouldHaveSingleChange(diffs!);
}
catch (Exception ex)
{
exception = ex;
};
exception.ShouldBeOfType<ArgumentNullException>();
}
[Theory(DisplayName = "ShouldHaveSingleChange throws when input length not exactly 1")]
[MemberData(nameof(GetDiffLists))]
public void Test002(IReadOnlyList<IDiff> diffs)
{
Exception? exception = null;
try
{
diffs.ShouldHaveSingleChange();
}
catch (Exception ex)
{
exception = ex;
};
exception.ShouldBeOfType<EqualException>();
}
[Fact(DisplayName = "ShouldHaveSingleChange returns the single diff in input when there is only one")]
public void Test003()
{
var input = new IDiff[] { Mock.Of<IDiff>() };
var output = input.ShouldHaveSingleChange();
output.ShouldBe(input[0]);
}
internal static IEnumerable<object[]> GetDiffLists()
{
yield return new object[] { Array.Empty<IDiff>() };
yield return new object[]
{
new IDiff[]
{
Mock.Of<IDiff>(),
Mock.Of<IDiff>(),
}
};
}
}
}