public LoadFromFile ( string fileName ) : void | ||
fileName | string | |
Результат | void |
public void LoadFileInvalidFilenameTest() { const string wrongFilename = "VersionOne.ServiceHost.exe.config.wrong"; var config = new ServiceHostConfiguration(); var viewMock = MockRepository.StrictMock<IConfigurationView>(); Expect.Call(FacadeMock.CreateConfiguration()).Return(config); Expect.Call(viewMock.Controller).PropertyBehavior(); Expect.Call(FacadeMock.LoadConfigurationFromFile(wrongFilename)).Throw(new InvalidFilenameException(string.Empty)); Expect.Call(() => viewMock.ShowErrorMessage(string.Empty)).IgnoreArguments(); MockRepository.ReplayAll(); var controller = new ConfigurationFormController(FacadeMock, uiFactoryMock); controller.RegisterView(viewMock); controller.LoadFromFile(wrongFilename); MockRepository.VerifyAll(); }
public void LoadValidConfigurationFileTest() { var config = new ServiceHostConfiguration(); var coreServices = new[] { "Tests" }; var customServices = new[] { "QualityCenter" }; var viewMock = MockRepository.StrictMock<IConfigurationView>(); Expect.Call(FacadeMock.CreateConfiguration()).Return(config); Expect.Call(viewMock.Controller).Repeat.Once().PropertyBehavior(); Expect.Call(FacadeMock.LoadConfigurationFromFile(Filename)).Return(config); Expect.Call(() => FacadeMock.ResetConnection()); Expect.Call(uiFactoryMock.GetNextPage(GeneralPageKey, config, null)).IgnoreArguments().Return(null); Expect.Call(viewMock.HeaderText).Repeat.Once().PropertyBehavior(); Expect.Call(viewMock.CurrentControl).Repeat.Once().PropertyBehavior(); Expect.Call(uiFactoryMock.GetCoreServiceNames(config)).Return(coreServices); Expect.Call(uiFactoryMock.GetCustomServiceNames(config)).Return(customServices); Expect.Call(() => viewMock.SetServiceNodesAndRedraw(coreServices, customServices)); Expect.Call(() => viewMock.SetCoreServiceNodesEnabled(false)); MockRepository.ReplayAll(); var controller = new ConfigurationFormController(FacadeMock, uiFactoryMock); controller.RegisterView(viewMock); controller.LoadFromFile(Filename); Assert.AreEqual(Filename, controller.CurrentFileName); MockRepository.VerifyAll(); }
public void LoadFileInvalidConfigurationDataTest() { var entity = new P4ServiceEntity(); var config = new ServiceHostConfiguration(new BaseServiceEntity[] { entity }); var viewMock = MockRepository.StrictMock<IConfigurationView>(); Expect.Call(FacadeMock.CreateConfiguration()).Return(config); Expect.Call(viewMock.Controller).PropertyBehavior(); Expect.Call(FacadeMock.LoadConfigurationFromFile(Filename)).Return(config); Expect.Call(FacadeMock.CreateConfiguration()).Return(new ServiceHostConfiguration()); Expect.Call(() => viewMock.SetServiceNodesAndRedraw(null, null)); Expect.Call(() => viewMock.ShowErrorMessage(string.Empty)).IgnoreArguments(); MockRepository.ReplayAll(); var controller = new ConfigurationFormController(FacadeMock, uiFactoryMock); controller.RegisterView(viewMock); controller.LoadFromFile(Filename); MockRepository.VerifyAll(); }