public void TestNullableEnum()
        {
            CommandReflection.AddMappedType(typeof(EnumClass));
            var c1 = (EnumClass)CommandMapping.Parse("M999 Y1");

            Assert.IsTrue(c1.Y == EnumObject.A);
            Assert.IsTrue(c1.ToGCode() == "M999 X0 Y1");
            var c2 = (EnumClass)CommandMapping.Parse("M999 Y2");

            Assert.IsTrue(c2.Y == EnumObject.B);
            Assert.IsTrue(c2.ToGCode() == "M999 X0 Y2");
            var c3 = (EnumClass)CommandMapping.Parse("M999 Y5");

            Assert.IsTrue(c3.Y == (EnumObject)5);
            Assert.IsTrue(c3.ToGCode() == "M999 X0 Y5");
            var c4 = (EnumClass)CommandMapping.Parse("M999 Y");

            Assert.IsTrue(c4.Y == null);
            Assert.IsTrue(c4.ToGCode() == "M999 X0");
            var c5 = (EnumClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.Y == null);
            Assert.IsTrue(c5.ToGCode() == "M999 X0");
            var c6 = (EnumClass)CommandMapping.Parse("M999 Y-1.1");

            Assert.IsTrue(c6.Y == (EnumObject)(-1));
            Assert.IsTrue(c6.ToGCode() == "M999 X0 Y-1");
        }
        public void TestEnum()
        {
            CommandReflection.AddMappedType(typeof(EnumClass));
            var c1 = (EnumClass)CommandMapping.Parse("M999 X1");

            Assert.IsTrue(c1.X == EnumObject.A);
            Assert.IsTrue(c1.ToGCode() == "M999 X1");
            var c2 = (EnumClass)CommandMapping.Parse("M999 X2");

            Assert.IsTrue(c2.X == EnumObject.B);
            Assert.IsTrue(c2.ToGCode() == "M999 X2");
            var c3 = (EnumClass)CommandMapping.Parse("M999 X5");

            Assert.IsTrue(c3.X == (EnumObject)5);
            Assert.IsTrue(c3.ToGCode() == "M999 X5");
            var c4 = (EnumClass)CommandMapping.Parse("M999 X");

            Assert.IsTrue(c4.X == (EnumObject)0);
            Assert.IsTrue(c4.ToGCode() == "M999 X0");
            var c5 = (EnumClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.X == (EnumObject)0);
            Assert.IsTrue(c5.ToGCode() == "M999 X0");
            var c6 = (EnumClass)CommandMapping.Parse("M999 X-1.1");

            Assert.IsTrue(c6.X == (EnumObject)(-1));
            Assert.IsTrue(c6.ToGCode() == "M999 X-1");
        }
        public void TestNullableByte()
        {
            CommandReflection.AddMappedType(typeof(ByteClass));
            var c2 = (ByteClass)CommandMapping.Parse("M999 Y1.1");

            Assert.IsTrue(c2.Y == 1);
            Assert.IsTrue(c2.ToGCode() == "M999 X0 Y1");
            var c3 = (ByteClass)CommandMapping.Parse("M999 Y1");

            Assert.IsTrue(c3.Y == 1);
            Assert.IsTrue(c3.ToGCode() == "M999 X0 Y1");
            var c4 = (ByteClass)CommandMapping.Parse("M999 Y");

            Assert.IsTrue(c4.Y == null);
            Assert.IsTrue(c4.ToGCode() == "M999 X0");
            var c5 = (ByteClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.Y == null);
            Assert.IsTrue(c5.ToGCode() == "M999 X0");
        }
        public void TestByte()
        {
            CommandReflection.AddMappedType(typeof(ByteClass));
            var c2 = (ByteClass)CommandMapping.Parse("M999 X1.1");

            Assert.IsTrue(c2.X == 1);
            Assert.IsTrue(c2.ToGCode() == "M999 X1");
            var c3 = (ByteClass)CommandMapping.Parse("M999 X1");

            Assert.IsTrue(c3.X == 1);
            Assert.IsTrue(c3.ToGCode() == "M999 X1");
            var c4 = (ByteClass)CommandMapping.Parse("M999 X");

            Assert.IsTrue(c4.X == 0);
            Assert.IsTrue(c4.ToGCode() == "M999 X0");
            var c5 = (ByteClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.X == 0);
            Assert.IsTrue(c5.ToGCode() == "M999 X0");
        }
        public void TestDecimal()
        {
            CommandReflection.AddMappedType(typeof(DecimalClass));
            var c1 = (DecimalClass)CommandMapping.Parse("M999 X-1.1");

            Assert.IsTrue(c1.X == -1.1m);
            Assert.IsTrue(c1.ToGCode() == "M999 X-1.1");
            var c2 = (DecimalClass)CommandMapping.Parse("M999 X1.1");

            Assert.IsTrue(c2.X == 1.1m);
            Assert.IsTrue(c2.ToGCode() == "M999 X1.1");
            var c3 = (DecimalClass)CommandMapping.Parse("M999 X1");

            Assert.IsTrue(c3.X == 1);
            Assert.IsTrue(c3.ToGCode() == "M999 X1");
            var c4 = (DecimalClass)CommandMapping.Parse("M999 X");

            Assert.IsTrue(c4.X == 0);
            Assert.IsTrue(c4.ToGCode() == "M999 X0");
            var c5 = (DecimalClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.X == 0);
            Assert.IsTrue(c5.ToGCode() == "M999 X0");
        }
        public void TestBool()
        {
            CommandReflection.AddMappedType(typeof(BoolClass));
            var c1 = (BoolClass)CommandMapping.Parse("M999 X-1.1");

            Assert.IsTrue(c1.X == true);
            Assert.IsTrue(c1.ToGCode() == "M999 X");
            var c2 = (BoolClass)CommandMapping.Parse("M999 X1.1");

            Assert.IsTrue(c2.X == true);
            Assert.IsTrue(c2.ToGCode() == "M999 X");
            var c3 = (BoolClass)CommandMapping.Parse("M999 X1");

            Assert.IsTrue(c3.X == true);
            Assert.IsTrue(c3.ToGCode() == "M999 X");
            var c4 = (BoolClass)CommandMapping.Parse("M999 X");

            Assert.IsTrue(c4.X == true);
            Assert.IsTrue(c4.ToGCode() == "M999 X");
            var c5 = (BoolClass)CommandMapping.Parse("M999");

            Assert.IsTrue(c5.X == false);
            Assert.IsTrue(c5.ToGCode() == "M999");
        }
 public void CustomCommandAddType()
 {
     CommandReflection.ClearMappings();
     CommandReflection.AddMappedType(typeof(CustomCommand));
     var cmd = CommandMapping.Parse("M999 X");
 }