Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Ellis <matell@microsoft.com>2015-05-21 10:26:32 +0300
committerMatt Ellis <matell@microsoft.com>2015-05-21 10:26:32 +0300
commit4f9f06ce58d9734760abd46155b45b10d8f6b1b5 (patch)
tree25a56d75db78d105def5e17dcbfaba1ef2809342
parent9a86bb89e26c92afe9a0f61bed3dd757894b7499 (diff)
parent9b69834469f7f16f14595e33491bf0af82add130 (diff)
Merge pull request #1778 from bpschoch/dispatchproxytests
Improve use of Asserts in DispatchProxyTests
-rw-r--r--src/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs85
1 files changed, 7 insertions, 78 deletions
diff --git a/src/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs b/src/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
index cc2f9b7ee0..b7128fe756 100644
--- a/src/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
+++ b/src/System.Reflection.DispatchProxy/tests/DispatchProxyTests.cs
@@ -18,8 +18,7 @@ namespace DispatchProxyTests
TestType_IHelloService proxy = DispatchProxy.Create<TestType_IHelloService, TestDispatchProxy>();
Assert.NotNull(proxy);
- Assert.True(typeof(TestDispatchProxy).GetTypeInfo().IsAssignableFrom(proxy.GetType().GetTypeInfo()),
- String.Format("Proxy type {0} did not derive from {1}", proxy.GetType().Name, typeof(TestDispatchProxy).Name));
+ Assert.IsAssignableFrom<TestDispatchProxy>(proxy);
}
[Fact]
@@ -31,8 +30,7 @@ namespace DispatchProxyTests
Type[] implementedInterfaces = typeof(TestType_IHelloAndGoodbyeService).GetTypeInfo().ImplementedInterfaces.ToArray();
foreach (Type t in implementedInterfaces)
{
- Assert.True(t.GetTypeInfo().IsAssignableFrom(proxy.GetType().GetTypeInfo()),
- String.Format("Proxy type {0} did not derive from {1}", proxy.GetType().Name, t.Name));
+ Assert.IsAssignableFrom(t, proxy);
}
}
@@ -58,8 +56,7 @@ namespace DispatchProxyTests
Assert.NotNull(proxy1);
Assert.NotNull(proxy2);
- Assert.True(proxy1.GetType() == proxy2.GetType(),
- String.Format("First instance of proxy type was {0} but second was {1}", proxy1.GetType().Name, proxy2.GetType().Name));
+ Assert.IsType(proxy1.GetType(), proxy2);
}
[Fact]
@@ -102,93 +99,25 @@ namespace DispatchProxyTests
[Fact]
public static void Create_Using_Concrete_Proxy_Type_Throws_ArgumentException()
{
- ArgumentException caughtException = null;
-
- try
- {
- TestType_ConcreteClass proxy = DispatchProxy.Create<TestType_ConcreteClass, TestDispatchProxy>();
- }
- catch (ArgumentException ex)
- {
- caughtException = ex;
- }
- catch (Exception e)
- {
- Assert.True(false, String.Format("Caught unexpected exception {0}", e.ToString()));
- }
-
- Assert.True(caughtException != null, "Expected ArgumentException to be thrown");
- Assert.True(String.Equals(caughtException.ParamName, "T"),
- String.Format("Expected paramName 'T' but received '{0}'", caughtException.ParamName));
+ Assert.Throws<ArgumentException>("T", () => DispatchProxy.Create<TestType_ConcreteClass, TestDispatchProxy>());
}
[Fact]
public static void Create_Using_Sealed_BaseType_Throws_ArgumentException()
{
- ArgumentException caughtException = null;
-
- try
- {
- TestType_IHelloService proxy = DispatchProxy.Create<TestType_IHelloService, Sealed_TestDispatchProxy>();
- }
- catch (ArgumentException ex)
- {
- caughtException = ex;
- }
- catch (Exception e)
- {
- Assert.True(false, String.Format("Caught unexpected exception {0}", e.ToString()));
- }
-
- Assert.True(caughtException != null, "Expected ArgumentException to be thrown");
- Assert.True(String.Equals(caughtException.ParamName, "TProxy"),
- String.Format("Expected paramName 'TProxy' but received '{0}'", caughtException.ParamName));
+ Assert.Throws<ArgumentException>("TProxy", () => DispatchProxy.Create<TestType_IHelloService, Sealed_TestDispatchProxy>());
}
[Fact]
public static void Create_Using_Abstract_BaseType_Throws_ArgumentException()
{
- ArgumentException caughtException = null;
-
- try
- {
- TestType_IHelloService proxy = DispatchProxy.Create<TestType_IHelloService, Abstract_TestDispatchProxy>();
- }
- catch (ArgumentException ex)
- {
- caughtException = ex;
- }
- catch (Exception e)
- {
- Assert.True(false, String.Format("Caught unexpected exception {0}", e.ToString()));
- }
-
- Assert.True(caughtException != null, "Expected ArgumentException to be thrown");
- Assert.True(String.Equals(caughtException.ParamName, "TProxy"),
- String.Format("Expected paramName 'TProxy' but received '{0}'", caughtException.ParamName));
+ Assert.Throws<ArgumentException>("TProxy", () => DispatchProxy.Create<TestType_IHelloService, Abstract_TestDispatchProxy>());
}
[Fact]
public static void Create_Using_BaseType_Without_Default_Ctor_Throws_ArgumentException()
{
- ArgumentException caughtException = null;
-
- try
- {
- TestType_IHelloService proxy = DispatchProxy.Create<TestType_IHelloService, NoDefaultCtor_TestDispatchProxy>();
- }
- catch (ArgumentException ex)
- {
- caughtException = ex;
- }
- catch (Exception e)
- {
- Assert.True(false, String.Format("Caught unexpected exception {0}", e.ToString()));
- }
-
- Assert.True(caughtException != null, "Expected ArgumentException to be thrown");
- Assert.True(String.Equals(caughtException.ParamName, "TProxy"),
- String.Format("Expected paramName 'TProxy' but received '{0}'", caughtException.ParamName));
+ Assert.Throws<ArgumentException>("TProxy", () => DispatchProxy.Create<TestType_IHelloService, NoDefaultCtor_TestDispatchProxy>());
}
[Fact]