Exemple #1
0
        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);
        }
Exemple #2
0
        public void SendReceiveMessages()
        {
            // Create a receiver task.
            //
            void ReceiverAction()
            {
                DispatchEntry[] globalDispatchTable = SettingsAssemblyInitializer.GetGlobalDispatchTable();

                bool result = true;

                while (result)
                {
                    result = sharedChannel.WaitAndDispatchFrame(globalDispatchTable);
                }
            }

            using Task receiverTask1 = Task.Factory.StartNew(ReceiverAction, TaskCreationOptions.LongRunning);
            using Task receiverTask2 = Task.Factory.StartNew(ReceiverAction, TaskCreationOptions.LongRunning);

            // Setup callbacks to verify the message.
            //
            UnitTestProxy.StringViewElements.Callback =
                msg =>
            {
                Assert.Equal(1, msg.Item1.Id);
                Assert.Equal("Test_Name101239871", msg.Item1.String.Value);
                Assert.Equal(2, msg.Item2.Id);
                Assert.Equal("Test_Abc", msg.Item2.String.Value);
            };

            UnitTestProxy.StringViewArray.Callback =
                msg =>
            {
                Assert.Equal(1, msg.Id);
                Assert.Equal("cba", msg.Strings[3].Value);
            };

            UnitTestProxy.WideStringMultiMessage.Callback =
                msg =>
            {
                Assert.Equal(4, msg.StringMessages[0].Id);
                Assert.Equal("Test_Name45659876", msg.StringMessages[0].Strings[3].Value);
            };

            int i = 0;

            while (i++ < 10000)
            {
                {
                    var msg = new StringViewElement();
                    msg.Id           = 1;
                    msg.String.Value = "Test_Name101239871";

                    sharedChannel.SendMessage(ref msg);
                }

                {
                    var msg = new StringViewElements();
                    msg.Item1.Id           = 1;
                    msg.Item1.String.Value = "Test_Name101239871";
                    msg.Item2.Id           = 2;
                    msg.Item2.String.Value = "Test_Abc";

                    sharedChannel.SendMessage(ref msg);
                }

                {
                    var msg = new StringViewArray();
                    msg.Id = 1;
                    msg.Strings[0].Value = "12345";
                    msg.Strings[1].Value = "54321";
                    msg.Strings[2].Value = "abc";
                    msg.Strings[3].Value = "cba";
                    msg.Strings[4].Value = "sbs";

                    sharedChannel.SendMessage(ref msg);
                }

                {
                    // WideStringMultiMessage is a class (due to usage of fixed size arrays).
                    //
                    var msg = new WideStringMultiMessage();
                    msg.StringMessages[0].Id = 4;
                    msg.StringMessages[0].Strings[0].Value = "Test_Name9876";
                    msg.StringMessages[0].Strings[1].Value = "Test_Name19876";
                    msg.StringMessages[0].Strings[2].Value = null;
                    msg.StringMessages[0].Strings[3].Value = "Test_Name45659876";
                    msg.StringMessages[0].Strings[4].Value = "Test_Name901239876";

                    sharedChannel.SendMessage(ref msg);
                }
            }

            sharedChannel.Sync.TerminateChannel.Store(true);

            receiverTask1.Wait();
            receiverTask2.Wait();
        }
Exemple #3
0
 public HashTableTests()
 {
     // Load the registry settings assemblies.
     //
     _ = SettingsAssemblyInitializer.GetGlobalDispatchTable();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SharedConfigManagerTests"/> class.
 /// </summary>
 public SharedConfigManagerTests()
 {
     // Load the registry settings assemblies.
     //
     _ = SettingsAssemblyInitializer.GetGlobalDispatchTable();
 }