PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
C# | 68 lines | 42 code | 10 blank | 16 comment | 0 complexity | 889df659268a90848f367839d0cd0d83 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.Collections.Generic;
19using System.Linq;
20using System.Text;
21using Microsoft.VisualStudio.TestTools.UnitTesting;
22using UIComposition.Modules.Employee.Tests.Mocks;
23
24namespace UIComposition.Modules.Employee.Tests
25{
26    [TestClass]
27    public class EmployeesDetailsPresenterFixture
28    {
29        MockEmployeesDetailsView view;
30
31        [TestInitialize]
32        public void SetUp()
33        {
34            view = new MockEmployeesDetailsView();
35        }
36
37        [TestMethod]
38        public void CanInitPresenter()
39        {
40            EmployeesDetailsPresenter presenter = CreatePresenter();
41
42            Assert.AreEqual(view, presenter.View);
43        }
44
45        [TestMethod]
46        public void ShouldSetModelOnDetailsView()
47        {
48            int employeeId = 10;
49            BusinessEntities.Employee employee = new BusinessEntities.Employee(employeeId) { LastName = "Con", FirstName = "Aaron" };
50            
51            EmployeesDetailsPresenter presenter = CreatePresenter();
52
53            Assert.IsNull(view.Model);
54            
55            presenter.SetSelectedEmployee(employee);
56
57            Assert.IsNotNull(view.Model);
58            Assert.AreEqual("Con", view.Model.SelectedEmployee.LastName);
59            Assert.AreEqual("Aaron", view.Model.SelectedEmployee.FirstName);
60            Assert.AreEqual(employeeId, view.Model.SelectedEmployee.EmployeeId);
61        }
62
63        private EmployeesDetailsPresenter CreatePresenter()
64        {
65            return new EmployeesDetailsPresenter(view);
66        }
67    }
68}