public void SaveToNonExistingFolder() { string newDirectory = Directory.GetCurrentDirectory() + "\\NewDirectory"; Assert.IsFalse(Directory.Exists(newDirectory), "The test directory should not exist"); Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments(). Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureGivenFolderExists(newDirectory); }); Expect.Call(delegate { fileSystem.AtomicSave(string.Empty, string.Empty); }).IgnoreArguments().Constraints( Rhino.Mocks.Constraints.Is.NotNull(), Rhino.Mocks.Constraints.Is.Anything()); mocks.ReplayAll(); state = new FileStateManager(fileSystem, executionEnvironment); state.StateFileDirectory = newDirectory; result = IntegrationResultMother.CreateSuccessful(); result.ProjectName = "my project"; state.SaveState(result); }
public void HandleExceptionSavingStateFile() { Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }); Expect.Call(() => fileSystem.AtomicSave(string.Empty, string.Empty)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull(), Rhino.Mocks.Constraints.Is.Anything()).Throw(new CruiseControlException()); mocks.ReplayAll(); state = new FileStateManager(fileSystem, executionEnvironment); Assert.That(delegate { state.SaveState(result); }, Throws.TypeOf<CruiseControlException>()); }
public void SaveProjectWithSpacesInName() { Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments(). Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }); Expect.Call(delegate { fileSystem.AtomicSave(string.Empty, string.Empty); }).IgnoreArguments().Constraints( Rhino.Mocks.Constraints.Is.NotNull(), Rhino.Mocks.Constraints.Is.Anything()); mocks.ReplayAll(); result = IntegrationResultMother.CreateSuccessful(); result.ProjectName = "my project"; state = new FileStateManager(fileSystem, executionEnvironment); state.SaveState(result); }
public void ShouldWriteXmlUsingUTF8Encoding() { Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }); Expect.Call(() => fileSystem.AtomicSave(string.Empty, string.Empty)).Constraints(Rhino.Mocks.Constraints.Is.NotNull(), new StartsWith("<?xml version=\"1.0\" encoding=\"utf-8\"?>")); mocks.ReplayAll(); result = IntegrationResultMother.CreateSuccessful(); result.ArtifactDirectory = "artifactDir"; state = new FileStateManager(fileSystem, executionEnvironment); state.SaveState(result); }
public void AttemptToSaveWithInvalidXml() { Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }); Expect.Call(delegate { fileSystem.AtomicSave(string.Empty, string.Empty); }).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull(), Rhino.Mocks.Constraints.Is.Anything()); mocks.ReplayAll(); result = IntegrationResultMother.CreateSuccessful(); result.Label = "<&/<>"; result.AddTaskResult("<badxml>>"); state = new FileStateManager(fileSystem, executionEnvironment); state.SaveState(result); }