示例#1
0
    static public (int statusCode, AttemptContinueWithCompositionEventReport responseReport) AttemptContinueWithCompositionEventAndCommit(
        CompositionLogRecordInFile.CompositionEvent compositionLogEvent,
        IFileStore processStoreFileStore,
        Action <string>?testContinueLogger = null)
    {
        var beginTime = CommonConversion.TimeStringViewForReport(DateTimeOffset.UtcNow);

        var totalStopwatch = System.Diagnostics.Stopwatch.StartNew();

        var testContinueResult = PersistentProcess.PersistentProcessLiveRepresentation.TestContinueWithCompositionEvent(
            compositionLogEvent: compositionLogEvent,
            fileStoreReader: processStoreFileStore,
            logger: testContinueLogger);

        var projectionResult = IProcessStoreReader.ProjectFileStoreReaderForAppendedCompositionLogEvent(
            originalFileStore: processStoreFileStore,
            compositionLogEvent: compositionLogEvent);

        if (testContinueResult.Ok?.projectedFiles == null)
        {
            return(statusCode : 400, new AttemptContinueWithCompositionEventReport
                   (
                       beginTime : beginTime,
                       compositionEvent : compositionLogEvent,
                       storeReductionReport : null,
                       storeReductionTimeSpentMilli : null,
                       totalTimeSpentMilli : (int)totalStopwatch.ElapsedMilliseconds,
                       result : Result <string, string> .err(testContinueResult.Err !)
                   ));
        }

        foreach (var projectedFilePathAndContent in testContinueResult.Ok.projectedFiles)
        {
            processStoreFileStore.SetFileContent(
                projectedFilePathAndContent.filePath, projectedFilePathAndContent.fileContent);
        }

        return(statusCode : 200, new AttemptContinueWithCompositionEventReport
               (
                   beginTime : beginTime,
                   compositionEvent : compositionLogEvent,
                   storeReductionReport : null,
                   storeReductionTimeSpentMilli : null,
                   totalTimeSpentMilli : (int)totalStopwatch.ElapsedMilliseconds,
                   result : Result <string, string> .ok("Successfully applied this composition event to the process.")
               ));
    }
示例#2
0
    public void Test_ProjectFileStoreReaderForAppendedCompositionLogEvent()
    {
        var compositionLogEvent = new CompositionLogRecordInFile.CompositionEvent
        {
            DeployAppConfigAndMigrateElmAppState =
                new ValueInFileStructure {
                LiteralStringUtf8 = "Actually not a valid value for an app config"
            }
        };

        var projectionResult = IProcessStoreReader.ProjectFileStoreReaderForAppendedCompositionLogEvent(
            originalFileStore: new EmptyFileStoreReader(),
            compositionLogEvent: compositionLogEvent);

        var processStoreReader = new ProcessStoreReaderInFileStore(projectionResult.projectedReader);

        var compositionLogRecords =
            processStoreReader.EnumerateSerializedCompositionLogRecordsReverse().ToImmutableList();

        Assert.IsTrue(compositionLogRecords.Any());
    }