public async Task FreeSharedMemoryMapsForInvocation_VerifySuccess() { // Prepare content string invocationId1 = Guid.NewGuid().ToString(); string invocationId2 = Guid.NewGuid().ToString(); string content = "foobar"; using (SharedMemoryManager manager = new SharedMemoryManager(_loggerFactory, _mapAccessor)) { // Put content into shared memory and add mapping to invocations SharedMemoryMetadata metadata1 = await manager.PutObjectAsync(content); string mapName1 = metadata1.MemoryMapName; manager.AddSharedMemoryMapForInvocation(invocationId1, mapName1); SharedMemoryMetadata metadata2 = await manager.PutObjectAsync(content); string mapName2 = metadata2.MemoryMapName; manager.AddSharedMemoryMapForInvocation(invocationId2, mapName2); // Free the shared memory maps for invocation1 and try top open it after freeing; should not open Assert.True(manager.TryFreeSharedMemoryMapsForInvocation(invocationId1)); Assert.False(_mapAccessor.TryOpen(mapName1, out _)); // Shared memory maps for invocation2 should still be available to open Assert.True(_mapAccessor.TryOpen(mapName2, out MemoryMappedFile mmf)); mmf.Dispose(); } }
public void FreeNonExistentInvocationIdSharedMemoryMaps_VerifySuccess() { string invocationId = Guid.NewGuid().ToString(); using (SharedMemoryManager manager = new SharedMemoryManager(_loggerFactory, _mapAccessor)) { Assert.True(manager.TryFreeSharedMemoryMapsForInvocation(invocationId)); } }