Beispiel #1
0
        public void Decode_SampleObject_ShouldEncodeCorrect(string raw)
        {
            var decoded = ObjectParser.Decode <ObjectSample>(raw);
            var encoded = ObjectParser.Encode(decoded);

            Assert.AreEqual(raw, encoded);
        }
Beispiel #2
0
        public void Decode_SampleObject_ExtraPropertiesShouldBeSave()
        {
            var input = "10:hello:33:9";

            var actual = ObjectParser.Decode <ObjectSample>(input);

            Assert.AreEqual(9, actual.X);
            Assert.AreEqual(1, actual.WithoutLoaded.Count);
            Assert.AreEqual("hello", actual.WithoutLoaded["10"]);
        }
Beispiel #3
0
        public void Decode_MultipleSense_ShouldBeCorrect()
        {
            var input    = "1~|~2";
            var expected = new MultipleSense()
            {
                X1 = 2
            };

            var actual = ObjectParser.Decode <MultipleSense>(input);

            actual.Should().BeEquivalentTo(expected);
        }
Beispiel #4
0
        public void Decode_SampleContainer_ShouldRecursiveDecodeCorrect()
        {
            var expected = new SampleContainer()
            {
                Sample1 = new ObjectSample()
                {
                    X = 1.3
                },
                Sample2 = new ObjectSample()
                {
                    X = 11
                }
            };
            const string input = "1~33:1.3~2~33:11";

            var decoded = ObjectParser.Decode <SampleContainer>(input);

            decoded.Should().BeEquivalentTo(expected);
        }
 public void Decode()
 {
     ObjectParser.Decode <LargeObject>(largeRaw);
 }
Beispiel #6
0
 public void Decode_SampleObject_ThrowExceptionIfHaveError(string input)
 {
     Assert.Throws(typeof(Exception), () => ObjectParser.Decode <ObjectSample>(input));
 }
Beispiel #7
0
        public void Decode_SampleObject_ShouldDecodeCorrect(string raw, double expected)
        {
            var actual = ObjectParser.Decode <ObjectSample>(raw);

            Assert.AreEqual(expected, actual.X);
        }
Beispiel #8
0
        public void Decode_AllTypes_ShouldNotThrowException()
        {
            var all = ObjectParser.Encode(new AllTypes());

            Assert.DoesNotThrow(() => ObjectParser.Decode <AllTypes>(all));
        }