コード例 #1
0
        public void TestMethodAssertThrowsLambda()
        {
            Assert.IsTrue(StfAssert.AssertThrows <ApplicationException>(
                              "true",
                              () => MethodWithParamCanThrow <ApplicationException>(true)));

            Assert.IsFalse(StfAssert.AssertThrows <ApplicationException>(
                               "false",
                               () => MethodWithParamCanThrow <ApplicationException>(false)));
        }
コード例 #2
0
        public void TestMethodProxyObjectCreatedForPluginWithMatchingInterface()
        {
            // need to load the UnitTest plug-ins
            LoadAdditionalStfPlugins(".", "Stf.UnitTestPlugin*.dll");

            var sp2 = Get <IStfUnitTestPlugin2>();

            StfAssert.IsNotNull(
                "Has interface",
                typeof(StfUnitTestPlugin2).GetInterface(typeof(IStfUnitTestPlugin2).Name));

            StfAssert.AssertThrows <InvalidCastException>(
                "Unit test plugin is a proxy object",
                // ReSharper disable once UnusedVariable
                () => { var stfUnitTestPlugin2 = (StfUnitTestPlugin2)sp2; });
        }
コード例 #3
0
 public void TestMethodUnknownTypeThrowsException()
 {
     StfAssert.AssertThrows <StfTypeResolutionException>("Resolve unknown for STF type", () => Get <StfTypeResolutionException>());
     StfAssert.AssertThrows <StfTypeResolutionException>("Resolve unknown for STF type", () => Get <int>());
 }
コード例 #4
0
 public void TestMethodAssertThrows()
 {
     Assert.IsTrue(StfAssert.AssertThrows <NotImplementedException>("true", ThrowNotImplementedException));
     Assert.IsFalse(StfAssert.AssertThrows <ArgumentException>("false", ThrowNotImplementedException));
 }