From 145aa87053aca6516db9cd5684f7d621a3572e67 Mon Sep 17 00:00:00 2001 From: Szabo Bogdan Date: Tue, 19 Dec 2017 10:55:02 +0200 Subject: [PATCH] instace use the object should --- core/fluentasserts/core/base.d | 2 +- core/fluentasserts/core/objects.d | 4 ++++ test/class.d | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/fluentasserts/core/base.d b/core/fluentasserts/core/base.d index 02721e2..1d3754d 100644 --- a/core/fluentasserts/core/base.d +++ b/core/fluentasserts/core/base.d @@ -503,7 +503,7 @@ auto should(T)(lazy T testData) { auto callable = ({ testData; }); return ShouldCallable!(typeof(callable))(callable); } else static if(!returned) { - static if(is(T == class)) { + static if(is(T == class) || is(T == interface)) { return ShouldObject!T(testData.evaluate); } else static if(is(T == string)) { return ShouldString(testData.evaluate); diff --git a/core/fluentasserts/core/objects.d b/core/fluentasserts/core/objects.d index 6aac7fd..2d587b1 100644 --- a/core/fluentasserts/core/objects.d +++ b/core/fluentasserts/core/objects.d @@ -124,8 +124,12 @@ unittest { class OtherClass { } auto someObject = new BaseClass; + MyInterface someInterface = new BaseClass; auto otherObject = new OtherClass; + someInterface.should.be.instanceOf!MyInterface; + someInterface.should.be.instanceOf!BaseClass; + someObject.should.be.instanceOf!MyInterface; auto msg = ({ diff --git a/test/class.d b/test/class.d index fe7b34e..b34c672 100644 --- a/test/class.d +++ b/test/class.d @@ -13,4 +13,4 @@ class Foo { void bar2() { enforce(false); } -} \ No newline at end of file +}