public BaseSharedChannelBenchmark() { globalChannelMemoryRegionView = SharedMemoryRegionView.Create <MlosProxyInternal.GlobalMemoryRegion>(GlobalMemoryMapName, SharedMemorySize); sharedChannelMemoryMapView = SharedMemoryMapView.Create(SharedChannelMemoryMapName, SharedMemorySize); MlosProxyInternal.GlobalMemoryRegion globalMemoryRegion = globalChannelMemoryRegionView.MemoryRegion(); sharedChannel = new TestSharedChannel(sharedChannelMemoryMapView, globalMemoryRegion.ControlChannelSynchronization); settingsAssemblyManager.RegisterAssembly(typeof(MlosContext).Assembly); settingsAssemblyManager.RegisterAssembly(typeof(AssemblyInitializer).Assembly); // Preallocate class type messages to avoid heap allocations. // stringViewArray = new StringViewArray(); stringViewArray.Id = 1; stringViewArray.Strings[0].Value = "12345"; stringViewArray.Strings[1].Value = "54321"; stringViewArray.Strings[2].Value = "abc"; stringViewArray.Strings[3].Value = "cba"; stringViewArray.Strings[4].Value = "sbs"; wideStringMultiMessage = new WideStringMultiMessage(); wideStringMultiMessage.StringMessages[0].Id = 4; wideStringMultiMessage.StringMessages[0].Strings[0].Value = "Test_Name9876"; wideStringMultiMessage.StringMessages[0].Strings[1].Value = "Test_Name19876"; wideStringMultiMessage.StringMessages[0].Strings[2].Value = "Test_Name1239876"; wideStringMultiMessage.StringMessages[0].Strings[3].Value = "Test_Name45659876"; wideStringMultiMessage.StringMessages[0].Strings[4].Value = "Test_Name901239876"; pointMessage.X = 4; pointMessage.Y = 5; }
public SharedChannelTests() { // Load the registry settings assemblies. // _ = SettingsAssemblyInitializer.GetGlobalDispatchTable(); // Initialize shared channel. // globalChannelMemoryRegionView = SharedMemoryRegionView.Create <MlosProxyInternal.GlobalMemoryRegion>(GlobalMemoryMapName, SharedMemorySize); sharedChannelMemoryMapView = SharedMemoryMapView.Create(SharedChannelMemoryMapName, SharedMemorySize); MlosProxyInternal.GlobalMemoryRegion globalMemoryRegion = globalChannelMemoryRegionView.MemoryRegion(); sharedChannel = new TestSharedChannel(sharedChannelMemoryMapView, globalMemoryRegion.ControlChannelSynchronization); }
public void VerifySharedMemoryMapUnlink() { // Create a new shared memory maps. // var newsSharedChannelMemoryMap = SharedMemoryMapView.Create(SharedMemoryMapName, SharedMemorySize); newsSharedChannelMemoryMap.CleanupOnClose = true; newsSharedChannelMemoryMap.Dispose(); try { // Verify we can open already created shared memory. // using var openedSharedChannelMemoryMap = SharedMemoryMapView.Open(SharedMemoryMapName, SharedMemorySize); newsSharedChannelMemoryMap.CleanupOnClose = true; Assert.False(true, "Shared memory map should be deleted"); } catch (FileNotFoundException) { // We are expecting failure. // } }