blob: 49f67ac77f2ac24e4ee1e495b306aa11ef54aa8b (
plain)
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
|
using System;
using System.Data;
using Marina.Infrastructure;
using MbUnit.Framework;
namespace Marina.Test.Unit.Infrastructure {
[TestFixture]
public class TransformerTest {
[Test]
public void Should_be_able_to_cast_to_the_actual_type_of_the_underlying_object( ) {
object item = new Item( );
Item result = CreateSUT( item ).To< Item >( );
Assert.AreEqual( item, result );
}
[ExpectedException( typeof( NullReferenceException ) )]
[Test]
public void Should_not_be_able_to_cast_from_null_to_a_type( ) {
CreateSUT( null ).To< Item >( );
}
[ExpectedException( typeof( InvalidCastException ) )]
[Test]
public void Should_not_be_able_to_cast_from_one_instance_to_a_non_assignable_type( ) {
Item item = new Item( );
CreateSUT( item ).To< IDbConnection >( );
}
private ITransformer CreateSUT( object item ) {
return new Transformer( item );
}
private class Item {}
}
}
|