コード例 #1
0
            public void ContextSetup()
            {
                var masterModel = new MasterModel();

                _project1 = masterModel.CreateProject(); //1
                _project2 = masterModel.CreateProject(); //2

                var server1 = masterModel.CreateCruiseServer(x =>
                {
                    x.Url  = "http://www.example.com/1";
                    x.Name = "1";
                });
                var server2 = masterModel.CreateCruiseServer(x =>
                {
                    x.Url  = "http://www.example.com/2";
                    x.Name = "2";
                });

                var statusProvider = S <ISystemStatusProvider>();

                statusProvider.Stub(x => x.GetSystemStatus())
                .Return(masterModel);

                var cruiseProjectProvider = S <ICruiseProjectModelProvider>();
                var projectResponse1      = NetworkResponse.Success(new CcProjectCollectionViewModel
                {
                    Items = new[] { new CcProjectViewModel {
                                        Name = "1.1"
                                    }, new CcProjectViewModel {
                                        Name = "1.2"
                                    } }
                });
                var projectResponse2 = NetworkResponse.Success(new CcProjectCollectionViewModel
                {
                    Items = new[] { new CcProjectViewModel {
                                        Name = "2.1"
                                    }, new CcProjectViewModel {
                                        Name = "2.2"
                                    } }
                });

                cruiseProjectProvider.Stub(x => x.GetProjects(server1.Id)).Return(projectResponse1);
                cruiseProjectProvider.Stub(x => x.GetProjects(server2.Id)).Return(projectResponse2);

                var mapper = new StubMapper()
                             .StubResult(new[]
                {
                    new EditProjectCruiseServerViewModel {
                        Url = "Mapped 1", Id = server1.Id
                    },
                    new EditProjectCruiseServerViewModel {
                        Url = "Mapped 2", Id = server2.Id
                    }
                });
                var provider = new AdminViewModelProvider(statusProvider, mapper, cruiseProjectProvider);

                _result = provider.GetEditProjectViewModel(null);
            }
コード例 #2
0
            public void ContextSetup()
            {
                var masterModel = new MasterModel();

                var statusProvider = S <ISystemStatusProvider>();

                statusProvider.Stub(x => x.GetSystemStatus())
                .Return(masterModel);

                IMapper doNotUseMapper = null;

                var provider = new AdminViewModelProvider(statusProvider, doNotUseMapper, null);

                _thrown = ExpectException <ArgumentException>(() => { provider.GetEditProjectViewModel(Guid.NewGuid()); });
            }
コード例 #3
0
            public void ContextSetup()
            {
                _projectViewModel = new EditProjectViewModel {
                    Name = "I'm Mapped"
                };

                var masterModel            = new MasterModel();
                var project1               = masterModel.CreateProject(); //1
                var projectWeAreLookingFor = masterModel.CreateProject(); //2
                var project3               = masterModel.CreateProject(); //3

                var server1 = masterModel.CreateCruiseServer(x =>
                {
                    x.Url  = "http://www.example.com/1";
                    x.Name = "1";
                });
                var server2 = masterModel.CreateCruiseServer(x =>
                {
                    x.Url  = "http://www.example.com/2";
                    x.Name = "2";
                });

                var statusProvider = S <ISystemStatusProvider>();

                statusProvider.Stub(x => x.GetSystemStatus())
                .Return(masterModel);

                var cruiseProjectProvider = S <ICruiseProjectModelProvider>();
                var projectResponse1      = NetworkResponse.Success(new CcProjectCollectionViewModel
                {
                    Items = new[] { new CcProjectViewModel {
                                        Name = "1.1"
                                    }, new CcProjectViewModel {
                                        Name = "1.2"
                                    } }
                });
                var projectResponse2 = NetworkResponse.Success(new CcProjectCollectionViewModel
                {
                    Items = new[] { new CcProjectViewModel {
                                        Name = "2.1"
                                    }, new CcProjectViewModel {
                                        Name = "2.2"
                                    } }
                });

                cruiseProjectProvider.Stub(x => x.GetProjects(server1.Id)).Return(projectResponse1);
                cruiseProjectProvider.Stub(x => x.GetProjects(server2.Id)).Return(projectResponse2);


                var mapper = S <IMapper>();

                mapper.Stub(x => x.Map <Project, EditProjectViewModel>(projectWeAreLookingFor))
                .Return(_projectViewModel);
                mapper.Stub(x => x.Map <CruiseServer[], EditProjectCruiseServerViewModel[]>(masterModel.CruiseServers))
                .Return(new[]
                {
                    new EditProjectCruiseServerViewModel {
                        Url = "foo 1", Id = server1.Id
                    },
                    new EditProjectCruiseServerViewModel {
                        Url = "foo 2", Id = server2.Id
                    }
                });
                var provider = new AdminViewModelProvider(statusProvider, mapper, cruiseProjectProvider);

                _result = provider.GetEditProjectViewModel(projectWeAreLookingFor.Id);
            }