Beispiel #1
0
        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);
        }