public void ReadScriptExecutionStreams() { // Arrange var fileSystem = new MockFileSystem(); var scriptExecutionStreams = new ScriptExecutionDataStreams(new DataStreams() { Information = new ScriptExecutionStorage.DataTypes.StreamRecord[] { new ScriptExecutionStorage.DataTypes.StreamRecord { Time = DateTime.Today, Message = "Info" } }, Debug = new ScriptExecutionStorage.DataTypes.StreamRecord[] { new ScriptExecutionStorage.DataTypes.StreamRecord { Time = DateTime.Today, Message = "Debug" } }, Error = new ScriptExecutionStorage.DataTypes.StreamRecord[] { new ScriptExecutionStorage.DataTypes.StreamRecord { Time = DateTime.Today, Message = "Error" } }, Verbose = new ScriptExecutionStorage.DataTypes.StreamRecord[] { new ScriptExecutionStorage.DataTypes.StreamRecord { Time = DateTime.Today, Message = "Verbose" } }, Warning = new ScriptExecutionStorage.DataTypes.StreamRecord[] { new ScriptExecutionStorage.DataTypes.StreamRecord { Time = DateTime.Today, Message = "Warning" } } }); var scriptExecutionJson = JsonConvert.SerializeObject(_scriptExecution); var scriptExecutionStreamsJson = JsonConvert.SerializeObject(scriptExecutionStreams); fileSystem.Directory.CreateDirectory(Path.Combine(_rootFolder, _userId, _scriptId)); fileSystem.File.WriteAllText(Path.Combine(_rootFolder, _userId, _scriptId, ScriptExecutionFileNames.ScriptExecution), scriptExecutionJson); fileSystem.File.WriteAllText(Path.Combine(_rootFolder, _userId, _scriptId, ScriptExecutionFileNames.ScriptExecutionStreams), scriptExecutionStreamsJson); // Act var fileStoreReader = new ScriptExecutionFileReader(_logger, _rootFolder, _userId, _scriptId, fileSystem); var actual = fileStoreReader.ReadScriptExecutionDataStreams(); // Assert Assert.AreEqual(scriptExecutionStreams.Streams.Debug[0].Time, actual.Streams.Debug[0].Time); Assert.AreEqual(scriptExecutionStreams.Streams.Debug[0].Message, actual.Streams.Debug[0].Message); Assert.AreEqual(scriptExecutionStreams.Streams.Information[0].Time, actual.Streams.Information[0].Time); Assert.AreEqual(scriptExecutionStreams.Streams.Information[0].Message, actual.Streams.Information[0].Message); Assert.AreEqual(scriptExecutionStreams.Streams.Warning[0].Time, actual.Streams.Warning[0].Time); Assert.AreEqual(scriptExecutionStreams.Streams.Warning[0].Message, actual.Streams.Warning[0].Message); Assert.AreEqual(scriptExecutionStreams.Streams.Error[0].Time, actual.Streams.Error[0].Time); Assert.AreEqual(scriptExecutionStreams.Streams.Error[0].Message, actual.Streams.Error[0].Message); Assert.AreEqual(scriptExecutionStreams.Streams.Verbose[0].Time, actual.Streams.Verbose[0].Time); Assert.AreEqual(scriptExecutionStreams.Streams.Verbose[0].Message, actual.Streams.Verbose[0].Message); }
public void ReadScriptExecution() { // Arrange var fileSystem = new MockFileSystem(); var scriptExecutionJson = JsonConvert.SerializeObject(_scriptExecution); fileSystem.Directory.CreateDirectory(Path.Combine(_rootFolder, _userId, _scriptId)); fileSystem.File.WriteAllText(Path.Combine(_rootFolder, _userId, _scriptId, ScriptExecutionFileNames.ScriptExecution), scriptExecutionJson); // Act var fileStoreReader = new ScriptExecutionFileReader(_logger, _rootFolder, _userId, _scriptId, fileSystem); var actual = fileStoreReader.ReadScriptExecution(); // Assert Assert.AreEqual(_scriptExecution.Name, actual.Name); Assert.AreEqual(_scriptExecution.Id, actual.Id); Assert.AreEqual(_scriptExecution.OutputObjectsFormat, actual.OutputObjectsFormat); Assert.AreEqual(_scriptExecution.Reason, actual.Reason); Assert.AreEqual(_scriptExecution.State, actual.State); }
public void ReadScriptExecutionOutput() { // Arrange var fileSystem = new MockFileSystem(); var scriptExecutionOutput = new ScriptExecutionOutput { OutputObjects = new[] { "TestObject1", "TestObject2" } }; var scriptExecutionJson = JsonConvert.SerializeObject(_scriptExecution); var scriptExecutionOutputJson = JsonConvert.SerializeObject(scriptExecutionOutput); fileSystem.Directory.CreateDirectory(Path.Combine(_rootFolder, _userId, _scriptId)); fileSystem.File.WriteAllText(Path.Combine(_rootFolder, _userId, _scriptId, ScriptExecutionFileNames.ScriptExecution), scriptExecutionJson); fileSystem.File.WriteAllText(Path.Combine(_rootFolder, _userId, _scriptId, ScriptExecutionFileNames.ScriptExecutionOutput), scriptExecutionOutputJson); // Act var fileStoreReader = new ScriptExecutionFileReader(_logger, _rootFolder, _userId, _scriptId, fileSystem); var actual = fileStoreReader.ReadScriptExecutionOutput(); // Assert Assert.AreEqual(2, actual.OutputObjects.Length); Assert.AreEqual(scriptExecutionOutput.OutputObjects[0], actual.OutputObjects[0]); Assert.AreEqual(scriptExecutionOutput.OutputObjects[1], actual.OutputObjects[1]); }