From 9d05e136c7fde8c6812a09c015ca38306d3dbb53 Mon Sep 17 00:00:00 2001 From: Jean-Marc Prieur Date: Tue, 8 Oct 2024 16:45:40 -0700 Subject: [PATCH] Fix tests (#3068) --- .../CacheEncryptionTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs b/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs index c2db4653b..ca35a9259 100644 --- a/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs +++ b/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs @@ -65,7 +65,7 @@ private byte[] GetFirstCacheValue(MemoryCache memoryCache) .GetType() .GetField("_entries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .GetValue(content1) as IDictionary)!; -#elif NET8_0_OR_GREATER +#elif NET8_0 dynamic content1 = memoryCache .GetType() .GetField("_coherentState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! @@ -74,6 +74,15 @@ private byte[] GetFirstCacheValue(MemoryCache memoryCache) .GetType() .GetField("_stringEntries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) .GetValue(content1) as IDictionary)!; +#elif NET9_0_OR_GREATER + dynamic content1 = memoryCache + .GetType() + .GetField("_coherentState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! + .GetValue(memoryCache)!; + memoryCacheContent = (content1? + .GetType() + .GetProperty("EntriesCollection", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) + .GetValue(content1) as IDictionary)!; #else memoryCacheContent = (memoryCache .GetType()