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