Пример #1
0
        public void TestDeltaValueOperatorForDecodingIntegerValue()
        {
            Assert.AreEqual(new IntegerValue(45),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeValue(new IntegerValue(15),
                                                                                             new IntegerValue(30), null));
            Assert.AreEqual(new IntegerValue(30),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeValue(new IntegerValue(-15),
                                                                                             new IntegerValue(45), null));
            var field = new Scalar("", FastType.I32, Operator.Delta, new IntegerValue(25), false);

            Assert.AreEqual(new IntegerValue(30),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeValue(new IntegerValue(5),
                                                                                             ScalarValue.Undefined,
                                                                                             field));
            var field2 = new Scalar("", FastType.I32, Operator.Delta, new IntegerValue(25), false);

            Assert.AreEqual(new IntegerValue(25),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeEmptyValue(
                                ScalarValue.Undefined, field2));
            Assert.AreEqual(new IntegerValue(5),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeEmptyValue(new IntegerValue(5),
                                                                                                  field));
            var field1 = new Scalar("", FastType.I32, Operator.Delta, ScalarValue.Undefined, true);

            Assert.AreEqual(ScalarValue.Undefined,
                            OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeEmptyValue(
                                ScalarValue.Undefined, field1));
        }
Пример #2
0
        public void TestIncrementOperatorWithNoDefaultValue()
        {
            var field = new Scalar("", FastType.U32, Operator.Increment, ScalarValue.Undefined, false);

            Assert.AreEqual(new IntegerValue(1),
                            OperatorCodec.GetCodec(Operator.Increment, FastType.I32).GetValueToEncode(
                                new IntegerValue(1), null, field));
            Assert.AreEqual(null,
                            OperatorCodec.GetCodec(Operator.Increment, FastType.I32).GetValueToEncode(
                                new IntegerValue(2), new IntegerValue(1), field));
        }
        public void TestDecodeForMandatoryFieldAndDefaultValue()
        {
            var field = new Scalar("", FastType.Decimal, Operator.Delta, Decimal(12000),
                                   false);

            Assert.AreEqual(Decimal(12000),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.Decimal).DecodeEmptyValue(ScalarValue.Undefined, field));
            Assert.AreEqual(Decimal(12100),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.Decimal).DecodeValue(Decimal(109, -1), Decimal(12000), field));
            Assert.AreEqual(Decimal(12150),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.Decimal).DecodeValue(Decimal(1094, -1), Decimal(12100), field));
            Assert.AreEqual(Decimal(12200),
                            OperatorCodec.GetCodec(Operator.Delta, FastType.Decimal).DecodeValue(Decimal(-1093, 1), Decimal(12150), field));
        }
Пример #4
0
 public void TestDeltaValueOperatorForDecodingIntegerValueWithEmptyPriorValue()
 {
     try
     {
         var field = new Scalar("", FastType.U32, Operator.Delta, new IntegerValue(25), false);
         OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeValue(new IntegerValue(30), null, field);
         //newly added implementation
         var field1 = new Scalar("", FastType.U32, Operator.Delta, ScalarValue.Undefined, false);
         Assert.AreEqual(ScalarValue.Undefined,
                         OperatorCodec.GetCodec(Operator.Delta, FastType.I32).DecodeEmptyValue(
                             ScalarValue.Undefined, field1));
         Assert.Fail();
     }
     catch (DynErrorException e)
     {
         Assert.AreEqual(DynError.MandatoryFieldNotPresent, e.Error);
     }
 }