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

/V2.2/trunk/Quickstarts/UI Composition/ViewInjection/Desktop/UIComposition.Modules.Employee.Tests/Views/EmployeesPresenterFixture.cs

#
C# | 79 lines | 51 code | 12 blank | 16 comment | 0 complexity | 34ba840139abb90e28b90dcf5433c197 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 System.Text;
19using System.Collections.Generic;
20using System.Linq;
21using Microsoft.VisualStudio.TestTools.UnitTesting;
22using UIComposition.Modules.Employee.Tests.Mocks;
23using UIComposition.Modules.Project;
24
25namespace UIComposition.Modules.Employee.Tests
26{
27    [TestClass]
28    public class EmployeesPresenterFixture
29    {
30        MockEmployeesView view;
31        MockEmployeesListPresenter listPresenter;
32        MockEmployeesController controller;
33
34        [TestInitialize]
35        public void SetUp()
36        {
37            view = new MockEmployeesView();
38            listPresenter = new MockEmployeesListPresenter();
39            controller = new MockEmployeesController();
40        }
41
42        [TestMethod]
43        public void CanInitPresenter()
44        {
45            EmployeesPresenter presenter = CreatePresenter();
46
47            Assert.IsNotNull(presenter);
48            Assert.AreEqual<IEmployeesView>(view, presenter.View);
49        }
50
51        [TestMethod]
52        public void ShouldAddEmployeesListViewToView()
53        {
54            Assert.IsFalse(view.SetHeaderCalled);
55
56            EmployeesPresenter presenter = CreatePresenter();
57
58            Assert.IsTrue(view.SetHeaderCalled);
59        }
60
61        [TestMethod]
62        public void RaiseEmployeeSelectedShouldCallController()
63        {
64            EmployeesPresenter presenter = CreatePresenter();
65
66            Assert.IsFalse(controller.ShowEmployeeDetailsCalled);
67
68            ((MockEmployeesListView)listPresenter.View).RaiseEmployeeSelected(null);
69
70            Assert.IsTrue(controller.ShowEmployeeDetailsCalled);           
71        }
72
73        private EmployeesPresenter CreatePresenter()
74        {
75            EmployeesPresenter presenter = new EmployeesPresenter(view, listPresenter, controller);
76            return presenter;
77        }
78    }
79}