-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathCopyConstructorTest.cs
61 lines (46 loc) · 1.52 KB
/
CopyConstructorTest.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
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Tynamix.ObjectFiller.Test
{
[TestClass]
public class CopyConstructorTest
{
[TestMethod]
public void WhenClassWithCopyConstructorIsCreatedNoExceptionShallBeThrown()
{
var f = new Filler<ClassWithCopyConstructorAndNormalConstructor>();
var cc = f.Create();
Assert.IsNotNull(cc);
}
[TestMethod]
public void WhenClassWithJustCopyConstructorIsCreatedAExceptionShallBeThrown()
{
var f = new Filler<ClassWithCopyConstructor>();
Assert.ThrowsException<InvalidOperationException>(() => f.Create());
}
}
public class ClassWithCopyConstructor
{
public ClassWithCopyConstructor(ClassWithCopyConstructor constructor)
{
Count1 = constructor.Count1;
Count2 = constructor.Count2;
}
public int Count1 { get; set; }
public int Count2 { get; set; }
}
public class ClassWithCopyConstructorAndNormalConstructor
{
public ClassWithCopyConstructorAndNormalConstructor(int count1, int count2)
{
Count1 = count1;
Count2 = count2;
}
public ClassWithCopyConstructorAndNormalConstructor(ClassWithCopyConstructorAndNormalConstructor constructor)
: this(constructor.Count1, constructor.Count2)
{
}
public int Count1 { get; set; }
public int Count2 { get; set; }
}
}