public void RecordProjectAsStartableAfterStopped() { var projectName = "Test Project #1"; SetupDefaultContent(); var stream1 = new MemoryStream(); var stream2 = new MemoryStream(); Mock.Get(fileSystem).SetupSequence(_fileSystem => _fileSystem.OpenOutputStream(persistanceFilePath)) .Returns(stream1).Returns(stream2); Mock.Get(executionEnvironment).Setup(_executionEnvironment => _executionEnvironment.GetDefaultProgramDataFolder(It.IsNotNull <ApplicationType>())) .Returns(applicationDataPath).Verifiable(); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.EnsureFolderExists(It.IsNotNull <string>())).Verifiable(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); stateManager.RecordProjectAsStopped(projectName); stateManager.RecordProjectAsStartable(projectName); var result = stateManager.CheckIfProjectCanStart(projectName); Assert.IsTrue(result, "Project state incorrect"); mocks.VerifyAll(); var expectedData1 = "<state><project>Test Project #3</project><project>Test Project #1</project></state>"; ValidateStreamData(stream1, expectedData1); var expectedData2 = "<state><project>Test Project #3</project></state>"; ValidateStreamData(stream2, expectedData2); }
public void RecordProjectAsStartableAfterStopped() { var projectName = "Test Project #1"; SetupDefaultContent(); var stream1 = InitialiseOutputStream(); var stream2 = InitialiseOutputStream(); Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()); mocks.ReplayAll(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); stateManager.RecordProjectAsStopped(projectName); stateManager.RecordProjectAsStartable(projectName); var result = stateManager.CheckIfProjectCanStart(projectName); Assert.IsTrue(result, "Project state incorrect"); mocks.VerifyAll(); var expectedData1 = "<state><project>Test Project #3</project><project>Test Project #1</project></state>"; ValidateStreamData(stream1, expectedData1); var expectedData2 = "<state><project>Test Project #3</project></state>"; ValidateStreamData(stream2, expectedData2); }
public void DefaultConstructorSetsPersistanceLocation() { // This is an indirect test - if the correct location is set, then the FileExists call // will be valid Mock.Get(executionEnvironment).Setup(_executionEnvironment => _executionEnvironment.GetDefaultProgramDataFolder(It.IsNotNull <ApplicationType>())) .Returns(applicationDataPath).Verifiable(); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.EnsureFolderExists(It.IsNotNull <string>())).Verifiable(); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.FileExists(persistanceFilePath)).Returns(false).Verifiable(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); stateManager.CheckIfProjectCanStart("Project"); mocks.VerifyAll(); }
public void DefaultConstructorSetsPersistanceLocation() { // This is an indirect test - if the correct location is set, then the FileExists call // will be valid Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()); Expect.Call(fileSystem.FileExists(persistanceFilePath)).Return(false); mocks.ReplayAll(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); stateManager.CheckIfProjectCanStart("Project"); mocks.VerifyAll(); }
public void CheckIfProjectCanStartKnownStartableProjectFromFile() { var projectName = "Test Project #4"; SetupDefaultContent(); Mock.Get(executionEnvironment).Setup(_executionEnvironment => _executionEnvironment.GetDefaultProgramDataFolder(It.IsNotNull <ApplicationType>())) .Returns(applicationDataPath).Verifiable(); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.EnsureFolderExists(It.IsNotNull <string>())).Verifiable(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); var result = stateManager.CheckIfProjectCanStart(projectName); Assert.IsTrue(result, "Project state incorrect"); mocks.VerifyAll(); }
public void CheckIfProjectCanStartKnownStartableProjectFromFile() { var projectName = "Test Project #4"; SetupDefaultContent(); Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath); Expect.Call(delegate { fileSystem.EnsureFolderExists(applicationDataPath); }).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()); mocks.ReplayAll(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); var result = stateManager.CheckIfProjectCanStart(projectName); Assert.IsTrue(result, "Project state incorrect"); mocks.VerifyAll(); }
public void RecordProjectAsStoppedAlreadyStopped() { var projectName = "Test Project #1"; SetupDefaultContent(); var stream = InitialiseOutputStream(); Mock.Get(executionEnvironment).Setup(_executionEnvironment => _executionEnvironment.GetDefaultProgramDataFolder(It.IsNotNull <ApplicationType>())) .Returns(applicationDataPath).Verifiable(); Mock.Get(fileSystem).Setup(_fileSystem => _fileSystem.EnsureFolderExists(It.IsNotNull <string>())).Verifiable(); stateManager = new XmlProjectStateManager(fileSystem, executionEnvironment); stateManager.RecordProjectAsStopped(projectName); var result = stateManager.CheckIfProjectCanStart(projectName); Assert.IsFalse(result, "Project state incorrect"); mocks.VerifyAll(); var expectedData = "<state><project>Test Project #3</project><project>Test Project #1</project></state>"; ValidateStreamData(stream, expectedData); }