public void SetClassObjectWithValidTypesDoesNotThrowException()
        {
            MyClassType sample = new MyClassType {
                Color  = "test",
                X      = 3,
                Hidden = true,
                Angle  = 3.14f
            };

            Assert.DoesNotThrow(() => instance.SetValuesFrom(sample));
            Assert.DoesNotThrow(output.Write);
        }
        public void SetFieldsAfterDisposingConnectorThrowsException()
        {
            MyClassType sample = new MyClassType {
                Color = "test"
            };

            connector.Dispose();
            Assert.Throws <ObjectDisposedException>(() => instance.SetValue("x", 3));
            Assert.Throws <ObjectDisposedException>(() => instance.SetValue("angle", 3.3));
            Assert.Throws <ObjectDisposedException>(() => instance.SetValue("color", "BLUE"));
            Assert.Throws <ObjectDisposedException>(() => instance.SetValue("hidden", false));
            Assert.Throws <ObjectDisposedException>(() => instance.SetValuesFrom(sample));
        }
        public void GetJsonSampleAfterDisposingConnectorThrowsException()
        {
            MyClassType obj = new MyClassType {
                Color  = "test",
                X      = 3,
                Hidden = true
            };

            SendAndTakeObjectSample(obj);
            Sample sample = samples.Single();

            connector.Dispose();
            Assert.Throws <ObjectDisposedException>(() => sample.Data.GetSampleAs <MyStructType>());
        }
        public void SendStructAndReceiveClassSample()
        {
            MyStructType obj = new MyStructType {
                Color  = "test",
                X      = 3,
                Hidden = true
            };

            SendAndTakeObjectSample(obj);
            Sample      sample   = samples.Single();
            MyClassType received = sample.Data.GetSampleAs <MyClassType>();

            Assert.AreEqual("test", received.Color);
            Assert.AreEqual(3, received.X);
            Assert.AreEqual(true, received.Hidden);
        }
        public void SetJsonObjDoesNotResetInstance()
        {
            output.Instance.SetValue("shapesize", 10);
            output.Instance.SetValue("x", 5);
            output.Instance.SetValue("y", 4);
            MyClassType obj = new MyClassType {
                Color  = "test",
                X      = 3,
                Hidden = true
            };

            output.Instance.SetValuesFrom(obj);
            output.Write();

            Assert.IsTrue(connector.Wait(1000));
            input.Take();
            Sample sample = samples.Single();

            Assert.AreEqual("test", sample.Data.GetStringValue("color"));
            Assert.AreEqual(3, sample.Data.GetInt32Value("x"));
            Assert.AreEqual(true, sample.Data.GetBoolValue("hidden"));
            Assert.AreEqual(4, sample.Data.GetInt32Value("y"));
            Assert.AreEqual(10, sample.Data.GetInt32Value("shapesize"));
        }