-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConvertable.cs
More file actions
55 lines (50 loc) · 1.65 KB
/
Convertable.cs
File metadata and controls
55 lines (50 loc) · 1.65 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
namespace AutoAdapter.Tests
{
public class Convertable
{
private AdapterTest Sut;
private TypeConverter Converter;
public Convertable()
{
Sut = new AdapterTest();
Converter = TypeDescriptor.GetConverter(typeof(IAdapterTest));
}
[Fact]
public void Converts()
{
Assert.False(typeof(IAdapterTest).IsAssignableFrom(Sut.GetType()));
//Assert.False(Sut.GetType().IsAssignableTo(typeof(IAdapterTest)));
IAdapterTest iSut = (IAdapterTest)Converter.ConvertFrom(Sut);
Assert.False(Sut.Called);
iSut.TestMethod();
Assert.True(Sut.Called);
}
[Fact]
public void ConvertsThroughStatic()
{
Assert.False(typeof(IAdapterTest).IsAssignableFrom(Sut.GetType()));
//Assert.False(Sut.GetType().IsAssignableTo(typeof(IAdapterTest)));
var iSut = Adapt<IAdapterTest>.From(Sut);
Assert.False(Sut.Called);
iSut.TestMethod();
Assert.True(Sut.Called);
}
[Fact]
public void ConvertsThroughIntermediary()
{
Assert.False(typeof(IAdapterTest).IsAssignableFrom(Sut.GetType()));
//Assert.False(Sut.GetType().IsAssignableTo(typeof(IAdapterTest)));
var iSut = Adapt.For(Sut).To<IAdapterTest>();
Assert.False(Sut.Called);
iSut.TestMethod();
Assert.True(Sut.Called);
}
}
}