-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestDataTests.cs
More file actions
71 lines (64 loc) · 2.67 KB
/
TestDataTests.cs
File metadata and controls
71 lines (64 loc) · 2.67 KB
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
using System;
using Xunit;
namespace IntelliTect.TestTools.TestFramework.Tests;
public class TestDataTests
{
[Fact]
public void BlockDataT1T2ThrowsExceptionOnDuplicateTypes()
{
var exception = Assert.Throws<TypeInitializationException>(() =>
{
var _ = new BlockData<int, int>(1, 2);
});
Assert.IsType<InvalidOperationException>(exception.InnerException);
Assert.Equal("Duplicate type found: Int32 appears multiple times. BlockData must use different types to avoid unexpected behavior by the TestCase DI Container.",
exception.InnerException.Message);
}
[Fact]
public void BlockDataT1T2T3ThrowsExceptionOnDuplicateTypes()
{
var exception = Assert.Throws<TypeInitializationException>(() =>
{
var _ = new BlockData<int, bool, int>(1, true, 2);
});
var invalidOp = Assert.IsType<InvalidOperationException>(exception.InnerException);
Assert.Equal("Duplicate type found: Int32 appears multiple times. BlockData must use different types to avoid unexpected behavior by the TestCase DI Container.",
invalidOp.Message);
}
[Fact]
public void BlockDataT1T2T3T4ThrowsExceptionOnDuplicateTypes()
{
var exception = Assert.Throws<TypeInitializationException>(() =>
{
var _ = new BlockData<bool, double, int, int>(false, 0.5, 1, 2);
});
Assert.NotNull(exception.InnerException);
Assert.Equal(typeof(InvalidOperationException), exception.InnerException.GetType());
Assert.Equal("Duplicate type found: Int32 appears multiple times. BlockData must use different types to avoid unexpected behavior by the TestCase DI Container.",
exception.InnerException.Message);
}
[Fact]
public void BlockDataT1T2DoesNotThrowExceptionWithUniqueTypes()
{
BlockData<int, bool> blockData = new(1, true);
Assert.Equal(1, blockData.Data1);
Assert.True(blockData.Data2);
}
[Fact]
public void BlockDataT1T2T3DoesNotThrowExceptionWithUniqueTypes()
{
BlockData<ArgumentException, Exception, bool> blockData = new(new ArgumentException(), new Exception(), true);
Assert.IsType<ArgumentException>(blockData.Data1);
Assert.IsType<Exception>(blockData.Data2);
Assert.True(blockData.Data3);
}
[Fact]
public void BlockDataT1T2T3T4DoesNotThrowExceptionWithUniqueTypes()
{
BlockData<int, bool, string, double> blockData = new(1, true, "", 0.5);
Assert.Equal(1, blockData.Data1);
Assert.True(blockData.Data2);
Assert.Equal("", blockData.Data3);
Assert.Equal(0.5, blockData.Data4);
}
}