PageRenderTime 19ms CodeModel.GetById 8ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/V4/PrismLibrary/Desktop/Prism.MefExtensions.Tests/BootstrapperFixtureBase.cs

#
C# | 47 lines | 28 code | 2 blank | 17 comment | 1 complexity | b4668f95e03f532a1a94ad0d517ed874 MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 4//===================================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===================================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===================================================================================
17using System;
18using Microsoft.Practices.Prism;
19using Microsoft.VisualStudio.TestTools.UnitTesting;
20
21namespace Microsoft.Practices.Prism.MefExtensions.Tests
22{
23    [TestClass]
24    public class BootstrapperFixtureBase
25    {
26        // TODO: Move to shared DLL
27        protected static void AssertExceptionThrownOnRun(Bootstrapper bootstrapper, Type expectedExceptionType, string expectedExceptionMessageSubstring)
28        {
29            bool exceptionThrown = false;
30            try
31            {
32                bootstrapper.Run();
33            }
34            catch (Exception ex)
35            {
36                Assert.AreEqual(expectedExceptionType, ex.GetType());
37                StringAssert.Contains(ex.Message, expectedExceptionMessageSubstring);
38                exceptionThrown = true;
39            }
40
41            if (!exceptionThrown)
42            {
43                Assert.Fail("Exception not thrown.");
44            }
45        }
46    }
47}