public void StoreProjectSnapshotStoresTheSnapShotAsXml()
        {
            // Arrange
            var snapshotsDir = Path.Combine("workingDir", defaultFolder);
            var snapshotFile = Path.Combine(snapshotsDir, "log20100101120000Lbuild.1.0.snapshot");
            var outputStream = new MemoryStream();
            var resultMock = InitialiseResultMock("workingDir");
            var snapShotMock = InitialiseSnapshot();
            var fileSystemMock = InitialiseFileSystemMockForOutput(snapshotFile, outputStream);
            var dataStore = new JsonFolderDataStore
                {
                    FileSystem = fileSystemMock
                };
            this.mocks.ReplayAll();

            // Act
            dataStore.StoreProjectSnapshot(resultMock, snapShotMock);

            // Assert
            this.mocks.VerifyAll();
            VerifyOutput(defaultJson, outputStream);
        }
        public void LoadProjectSnapshotReturnsNullForMissingSnapshot()
        {
            // Arrange
            var logFile = "log20100101120000Lbuild.1.0";
            var snapshotsDir = Path.Combine("workingDir", defaultFolder);
            var snapshotFile = Path.Combine(snapshotsDir, logFile + ".snapshot");
            var outputStream = new MemoryStream();
            var fileSystemMock = InitialiseFileSystemMockForInput(snapshotFile, null);
            var projectMock = InitialiseProjectMock("workingDir");
            var dataStore = new JsonFolderDataStore
                {
                    FileSystem = fileSystemMock
                };
            this.mocks.ReplayAll();

            // Act
            var snapshot = dataStore.LoadProjectSnapshot(projectMock, logFile + ".xml");

            // Assert
            this.mocks.VerifyAll();
            Assert.IsNull(snapshot);
        }
        public void LoadProjectSnapshotLoadsExistingSnapshot()
        {
            // Arrange
            var logFile = "log20100101120000Lbuild.1.0";
            var snapshotsDir = Path.Combine("workingDir", defaultFolder);
            var snapshotFile = Path.Combine(snapshotsDir, logFile + ".snapshot");
            var outputStream = new MemoryStream();
            var fileSystemMock = InitialiseFileSystemMockForInput(snapshotFile, defaultJson);
            var projectMock = InitialiseProjectMock("workingDir");
            var dataStore = new JsonFolderDataStore
                {
                    FileSystem = fileSystemMock
                };
            this.mocks.ReplayAll();

            // Act
            var snapshot = dataStore.LoadProjectSnapshot(projectMock, logFile + ".xml");

            // Assert
            this.mocks.VerifyAll();
            Assert.IsNotNull(snapshot);
            Assert.AreEqual("TestProject", snapshot.Name);
            Assert.AreEqual(
                DateTime.Parse("2010-01-01T12:00:00.00000+00:00", CultureInfo.InvariantCulture).ToUniversalTime(), 
                snapshot.TimeStarted);
            Assert.AreEqual(ItemBuildStatus.CompletedSuccess, snapshot.Status);
        }