public void ControllerDoesNotAddViewWhenShowDetailsIfIsAlreadyPresent()
        {
            container.RegisterType<IEmployeesDetailsPresenter, MockEmployeesDetailsPresenter>();
            container.RegisterType<IProjectsListPresenter, MockProjectsListPresenter>();

            var regionManager = new MockRegionManager();
            var detailsRegion = new MockRegion();
            regionManager.Regions.Add(RegionNames.DetailsRegion, detailsRegion);
            var scopedRegionManager = new MockRegionManager();
            scopedRegionManager.Regions.Add(RegionNames.TabRegion, new MockRegion());
            detailsRegion.AddReturnValue = scopedRegionManager;

            BusinessEntities.Employee employee = new BusinessEntities.Employee(10) { LastName = "Con", FirstName = "Aaron" };

            EmployeesController controller = new EmployeesController(container, regionManager);

            Assert.AreEqual<int>(0, detailsRegion.ViewsCount);

            controller.OnEmployeeSelected(employee);
            controller.OnEmployeeSelected(employee);

            Assert.AreEqual<int>(1, detailsRegion.ViewsCount);
            Assert.IsTrue(detailsRegion.ActivateCalled);
        }
        public void ControllerAddsViewWhenShowDetailsIfNotPresent()
        {
            container.RegisterType<IEmployeesDetailsPresenter, MockEmployeesDetailsPresenter>();
            container.RegisterType<IProjectsListPresenter, MockProjectsListPresenter>();

            var regionManager = new MockRegionManager();
            var detailsRegion = new MockRegion();
            regionManager.Regions.Add(RegionNames.DetailsRegion, detailsRegion);
            var scopedRegionManager = new MockRegionManager();
            scopedRegionManager.Regions.Add(RegionNames.TabRegion, new MockRegion());
            detailsRegion.AddReturnValue = scopedRegionManager;

            BusinessEntities.Employee employee1 = new BusinessEntities.Employee(10) { LastName = "Mock1", FirstName = "Employee1" };
            BusinessEntities.Employee employee2 = new BusinessEntities.Employee(11) { LastName = "Mock2", FirstName = "Employee2" };

            EmployeesController controller = new EmployeesController(container, regionManager);

            Assert.AreEqual<int>(0, detailsRegion.ViewsCount);

            controller.OnEmployeeSelected(employee1);
            controller.OnEmployeeSelected(employee2);

            Assert.AreEqual<int>(2, detailsRegion.ViewsCount);
        }
Esempio n. 3
0
 public void SetUp()
 {
     container = new MockUnityContainer();
     regionViewRegistry = new MockRegionContentRegistry();
     regionManager = new MockRegionManager();
 }
        public void ShowTheNewlyAddedViewInTheDetailsRegion()
        {
            container.RegisterType<IEmployeesDetailsPresenter, MockEmployeesDetailsPresenter>();
            container.RegisterType<IProjectsListPresenter, MockProjectsListPresenter>();

            var regionManager = new MockRegionManager();
            var detailsRegion = new MockRegion();
            regionManager.Regions.Add(RegionNames.DetailsRegion, detailsRegion);
            var scopedRegionManager = new MockRegionManager();
            scopedRegionManager.Regions.Add(RegionNames.TabRegion, new MockRegion());
            detailsRegion.AddReturnValue = scopedRegionManager;

            BusinessEntities.Employee employee1 = new BusinessEntities.Employee(10) { LastName = "Mock1", FirstName = "Employee1" };

            EmployeesController controller = new EmployeesController(container, regionManager);

            controller.OnEmployeeSelected(employee1);

            Assert.AreEqual<int>(1, detailsRegion.ViewsCount);
            Assert.IsTrue(detailsRegion.ActivateCalled);
        }
Esempio n. 5
0
 public void SetUp()
 {
     container = new MockUnityContainer();
     regionManager = new MockRegionManager();
 }