示例#1
0
        public void DisplayProjectDetails_Should_Set_Bug_Count_From_BugService()
        {
            MockRepository repo           = new MockRepository();
            IBugListView   mockBugView    = repo.StrictMock <IBugListView>();
            IBugService    mockBugService = repo.StrictMock <IBugService>();
            IProject       mockProject    = repo.StrictMock <IProject>();

            IBug[]      mockBugsArray = new IBug[] { repo.StrictMock <IBug>(), repo.StrictMock <IBug>() };
            List <IBug> mockBugs      = new List <IBug>(mockBugsArray);

            mockBugView.Expect(view => view.SelectedProject).Return(mockProject).Repeat.Twice();
            mockBugService.Expect(svc => svc.GetBugCountForProject(mockProject)).Return(200);
            mockBugView.Expect(view => view.TotalBugs).SetPropertyWithArgument(200);
            mockBugView.Expect(view => view.FilterQuery).Return(string.Empty).Repeat.Any();
            mockBugView.Expect(view => view.IsBusy).Return(false).Repeat.Any();
            mockBugView.Expect(view => view.IsBusy).SetPropertyAndIgnoreArgument().Repeat.Any();

            repo.ReplayAll();

            IBugListViewPresenter pres = new BugListViewPresenter(mockBugView, mockBugService);

            pres.DisplayProjectDetails();

            mockBugService.VerifyAllExpectations();
            mockBugView.VerifyAllExpectations();
        }
        public void Initalize_Should_Set_ProjectList_From_BugService()
        {
            MockRepository repo           = new MockRepository();
            IBugListView   mockBugView    = repo.StrictMock <IBugListView>();
            IBugService    mockBugService = repo.StrictMock <IBugService>();

            IProject[]      mockProjectsArray = new IProject[] { repo.StrictMock <IProject>(), repo.StrictMock <IProject>() };
            List <IProject> projects          = new List <IProject>(mockProjectsArray);

            mockBugService.Expect(svc => svc.GetProjects()).Return(projects);
            mockBugView.Expect(view => view.Projects).SetPropertyWithArgument(projects);
            mockBugView.Expect(view => view.FilterBy).Return(string.Empty).Repeat.Any();
            mockBugView.Expect(view => view.FilterValue).Return(string.Empty).Repeat.Any();
            mockBugView.Expect(view => view.IsBusy).Return(false).Repeat.Any();
            mockBugView.Expect(view => view.IsBusy).SetPropertyAndIgnoreArgument().Repeat.Any();

            repo.ReplayAll();

            IBugListViewPresenter pres = new BugListViewPresenter(mockBugView, mockBugService);

            pres.Initialize();

            mockBugService.VerifyAllExpectations();
            mockBugView.VerifyAllExpectations();
        }