public void TestNonDefaultValues() { TransportInst inst = TransportRegistry.Instance.CreateInst(INSTANCE_NAME, TRANSPORT_TYPE); ShmemInst shmemi = new ShmemInst(inst) { PoolSize = 16000000U, DatalinkControlSize = 2048U, DatalinkControlChunks = 64U, DatalinkReleaseDelay = 20000, MaxPacketSize = 2147481500u, MaxSamplesPerPacket = 20U, OptimumPacketSize = 2048u, QueueInitialPools = 20U, QueueMessagesPerPool = 20U, ThreadPerConnection = true }; Assert.AreEqual(16000000U, shmemi.PoolSize); Assert.AreEqual(2048U, shmemi.DatalinkControlSize); Assert.AreEqual(64U, shmemi.DatalinkControlChunks); Assert.AreEqual(20000, shmemi.DatalinkReleaseDelay); Assert.AreEqual(2147481500u, shmemi.MaxPacketSize); Assert.AreEqual(20U, shmemi.MaxSamplesPerPacket); Assert.AreEqual(INSTANCE_NAME, shmemi.Name); Assert.AreEqual(2048u, shmemi.OptimumPacketSize); Assert.AreEqual(20U, shmemi.QueueInitialPools); Assert.AreEqual(20U, shmemi.QueueMessagesPerPool); Assert.IsTrue(shmemi.ThreadPerConnection); TransportRegistry.Instance.RemoveInst(shmemi); }
public void TestDefaultValues() { TransportInst inst = TransportRegistry.Instance.CreateInst(INSTANCE_NAME, TRANSPORT_TYPE); ShmemInst shmemi = new ShmemInst(inst); Assert.IsFalse(string.IsNullOrWhiteSpace(shmemi.HostName)); Assert.AreEqual(16777216U, shmemi.PoolSize); Assert.IsFalse(string.IsNullOrWhiteSpace(shmemi.PoolName)); Assert.AreEqual(4096U, shmemi.DatalinkControlSize); Assert.AreEqual(32U, shmemi.DatalinkControlChunks); Assert.AreEqual(10000, shmemi.DatalinkReleaseDelay); Assert.IsTrue(shmemi.IsReliable); Assert.AreEqual(2147481599u, shmemi.MaxPacketSize); Assert.AreEqual(10U, shmemi.MaxSamplesPerPacket); Assert.AreEqual(INSTANCE_NAME, shmemi.Name); Assert.AreEqual(4096u, shmemi.OptimumPacketSize); Assert.AreEqual(5U, shmemi.QueueInitialPools); Assert.AreEqual(10U, shmemi.QueueMessagesPerPool); Assert.AreEqual(TRANSPORT_TYPE, shmemi.TransportType); Assert.IsFalse(shmemi.ThreadPerConnection); TransportRegistry.Instance.RemoveInst(shmemi); }
public void TestCreateInst() { // Create a RTPS UDP transport instance TransportInst inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "rtps_udp"); Assert.IsNotNull(inst); Assert.AreEqual(nameof(TestCreateInst), inst.Name); Assert.AreEqual("rtps_udp", inst.TransportType); RtpsUdpInst rui = new RtpsUdpInst(inst); Assert.IsNotNull(rui); TransportRegistry.Instance.RemoveInst(inst); // Create a UDP transport instance inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "udp"); Assert.IsNotNull(inst); Assert.AreEqual(nameof(TestCreateInst), inst.Name); Assert.AreEqual("udp", inst.TransportType); UdpInst udpi = new UdpInst(inst); Assert.IsNotNull(udpi); TransportRegistry.Instance.RemoveInst(inst); // Create a Multicast transport instance inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "multicast"); Assert.IsNotNull(inst); Assert.AreEqual(nameof(TestCreateInst), inst.Name); Assert.AreEqual("multicast", inst.TransportType); MulticastInst multicasti = new MulticastInst(inst); Assert.IsNotNull(multicasti); TransportRegistry.Instance.RemoveInst(inst); // Create a Multicast transport instance inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "tcp"); Assert.IsNotNull(inst); Assert.AreEqual(nameof(TestCreateInst), inst.Name); Assert.AreEqual("tcp", inst.TransportType); MulticastInst tcpi = new MulticastInst(inst); Assert.IsNotNull(tcpi); TransportRegistry.Instance.RemoveInst(inst); // Create a SharedMemory transport instance inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "shmem"); Assert.IsNotNull(inst); Assert.AreEqual(nameof(TestCreateInst), inst.Name); Assert.AreEqual("shmem", inst.TransportType); ShmemInst shmemi = new ShmemInst(inst); Assert.IsNotNull(shmemi); TransportRegistry.Instance.RemoveInst(inst); // Create a instance with an invalid transport type inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "quantic_teletransport"); Assert.IsNull(inst); // Try to create a transport instance with empty name bool exception = false; try { inst = TransportRegistry.Instance.CreateInst(null, "shmem"); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { inst = TransportRegistry.Instance.CreateInst(string.Empty, "shmem"); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); exception = false; try { inst = TransportRegistry.Instance.CreateInst(" ", "shmem"); } catch (Exception ex) { exception = true; Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException)); } Assert.IsTrue(exception); }