@@ -2067,4 +2067,133 @@ await store.CreateFunction(
20672067 interruptedFunctions . Any ( id => id == functionId1 ) . ShouldBeFalse ( ) ;
20682068 interruptedFunctions . Any ( id => id == functionId3 ) . ShouldBeFalse ( ) ;
20692069 }
2070+
2071+ public abstract Task GetResultsReturnsResultsForExistingFunctions ( ) ;
2072+ protected async Task GetResultsReturnsResultsForExistingFunctions ( Task < IFunctionStore > storeTask )
2073+ {
2074+ var store = await storeTask ;
2075+ var functionId1 = TestStoredId . Create ( ) ;
2076+ var functionId2 = StoredId . Create ( functionId1 . Type , Guid . NewGuid ( ) . ToString ( ) ) ;
2077+ var functionId3 = StoredId . Create ( functionId1 . Type , Guid . NewGuid ( ) . ToString ( ) ) ;
2078+
2079+ var result1 = "result1" . ToJson ( ) . ToUtf8Bytes ( ) ;
2080+ var result2 = "result2" . ToJson ( ) . ToUtf8Bytes ( ) ;
2081+
2082+ // Create function 1 and succeed with result1
2083+ await store . CreateFunction (
2084+ functionId1 ,
2085+ "humanInstanceId1" ,
2086+ param : Test . SimpleStoredParameter ,
2087+ leaseExpiration : DateTime . UtcNow . Ticks ,
2088+ postponeUntil : null ,
2089+ timestamp : DateTime . UtcNow . Ticks ,
2090+ parent : null ,
2091+ owner : ReplicaId . Empty
2092+ ) . ShouldNotBeNullAsync ( ) ;
2093+
2094+ await store . SucceedFunction (
2095+ functionId1 ,
2096+ result : result1 ,
2097+ timestamp : DateTime . UtcNow . Ticks ,
2098+ expectedReplica : ReplicaId . Empty ,
2099+ effects : null ,
2100+ messages : null ,
2101+ storageSession : null
2102+ ) . ShouldBeTrueAsync ( ) ;
2103+
2104+ // Create function 2 and succeed with result2
2105+ await store . CreateFunction (
2106+ functionId2 ,
2107+ "humanInstanceId2" ,
2108+ param : Test . SimpleStoredParameter ,
2109+ leaseExpiration : DateTime . UtcNow . Ticks ,
2110+ postponeUntil : null ,
2111+ timestamp : DateTime . UtcNow . Ticks ,
2112+ parent : null ,
2113+ owner : ReplicaId . Empty
2114+ ) . ShouldNotBeNullAsync ( ) ;
2115+
2116+ await store . SucceedFunction (
2117+ functionId2 ,
2118+ result : result2 ,
2119+ timestamp : DateTime . UtcNow . Ticks ,
2120+ expectedReplica : ReplicaId . Empty ,
2121+ effects : null ,
2122+ messages : null ,
2123+ storageSession : null
2124+ ) . ShouldBeTrueAsync ( ) ;
2125+
2126+ // Create function 3 with no result (just created, not completed)
2127+ await store . CreateFunction (
2128+ functionId3 ,
2129+ "humanInstanceId3" ,
2130+ param : Test . SimpleStoredParameter ,
2131+ leaseExpiration : DateTime . UtcNow . Ticks ,
2132+ postponeUntil : null ,
2133+ timestamp : DateTime . UtcNow . Ticks ,
2134+ parent : null ,
2135+ owner : null
2136+ ) . ShouldNotBeNullAsync ( ) ;
2137+
2138+ // Get results for all three functions
2139+ var results = await store . GetResults ( [ functionId1 , functionId2 , functionId3 ] ) ;
2140+
2141+ // Verify results
2142+ results . Count . ShouldBe ( 3 ) ;
2143+ results [ functionId1 ] . ShouldBe ( result1 ) ;
2144+ results [ functionId2 ] . ShouldBe ( result2 ) ;
2145+ results [ functionId3 ] . ShouldBeNull ( ) ;
2146+ }
2147+
2148+ public abstract Task GetResultsReturnsEmptyDictionaryForEmptyInput ( ) ;
2149+ protected async Task GetResultsReturnsEmptyDictionaryForEmptyInput ( Task < IFunctionStore > storeTask )
2150+ {
2151+ var store = await storeTask ;
2152+
2153+ var results = await store . GetResults ( [ ] ) ;
2154+
2155+ results . ShouldNotBeNull ( ) ;
2156+ results . Count . ShouldBe ( 0 ) ;
2157+ }
2158+
2159+ public abstract Task GetResultsReturnsOnlyExistingFunctionResults ( ) ;
2160+ protected async Task GetResultsReturnsOnlyExistingFunctionResults ( Task < IFunctionStore > storeTask )
2161+ {
2162+ var store = await storeTask ;
2163+ var existingFunctionId = TestStoredId . Create ( ) ;
2164+ var nonExistentFunctionId = StoredId . Create ( existingFunctionId . Type , Guid . NewGuid ( ) . ToString ( ) ) ;
2165+
2166+ var result = "my result" . ToJson ( ) . ToUtf8Bytes ( ) ;
2167+
2168+ // Create and succeed one function
2169+ await store . CreateFunction (
2170+ existingFunctionId ,
2171+ "humanInstanceId" ,
2172+ param : Test . SimpleStoredParameter ,
2173+ leaseExpiration : DateTime . UtcNow . Ticks ,
2174+ postponeUntil : null ,
2175+ timestamp : DateTime . UtcNow . Ticks ,
2176+ parent : null ,
2177+ owner : ReplicaId . Empty
2178+ ) . ShouldNotBeNullAsync ( ) ;
2179+
2180+ await store . SucceedFunction (
2181+ existingFunctionId ,
2182+ result : result ,
2183+ timestamp : DateTime . UtcNow . Ticks ,
2184+ expectedReplica : ReplicaId . Empty ,
2185+ effects : null ,
2186+ messages : null ,
2187+ storageSession : null
2188+ ) . ShouldBeTrueAsync ( ) ;
2189+
2190+ // Query for both existing and non-existent function
2191+ var results = await store . GetResults ( [ existingFunctionId , nonExistentFunctionId ] ) ;
2192+
2193+ // Should only return the existing function
2194+ results . Count . ShouldBe ( 1 ) ;
2195+ results . ContainsKey ( existingFunctionId ) . ShouldBeTrue ( ) ;
2196+ results [ existingFunctionId ] . ShouldBe ( result ) ;
2197+ results . ContainsKey ( nonExistentFunctionId ) . ShouldBeFalse ( ) ;
2198+ }
20702199}
0 commit comments