public void ExtendPack() { dynamic evt = new ExpandoObject(); evt.UnEqualCommandLine = "let's start a crazy process, and break the internet!"; evt.EqualCommandLine = "this one should be equivalent!"; evt.NumericSeed = 1111; List <string> listExtendTestScalarFunctions = new List <string>() { "extend x = pack(\"First\", \"Second\", \"Numeric\", 1234, \"Numeric2\", 4567)", //"extend text = strlen(\"1234567890\")", //"extend text = tostring(123)" }; foreach (string extendedScalarFunction in listExtendTestScalarFunctions) { ExtendOperator extendOperator = new ExtendOperator(extendedScalarFunction); string serializationOfExtend = RxKqlCommonFunctions.ToJson(extendOperator); ExtendOperator hydratedExtendOperator = RxKqlCommonFunctions.ToExtendOperator(serializationOfExtend); Assert.AreEqual(extendedScalarFunction, hydratedExtendOperator.ToString()); } // Positive test... var x = RunAtomicQuery(evt, "extend p = pack(\"First\", \"Second\", \"Numeric\", 1234, \"Numeric2\", 5678, \"FieldValueOfSeed\", NumericSeed)"); Assert.AreEqual(x[0].p.First.ToString(), "Second"); // Should be "Second" Assert.AreEqual(x[0].p.Numeric.ToString(), "1234"); // Should be "1234" Assert.AreEqual(x[0].p.Numeric2.ToString(), "5678"); // Should be "5678" Assert.AreEqual(x[0].p.FieldValueOfSeed, 1111); // Should be "5678" }
public void ExtendScalarConstAndPropSerializationDoubleQuoteTest() { string originalString = "extend text = AFieldName, intFive = 5, stringThree = \"Three\""; ExtendOperator extendOperator = new ExtendOperator(originalString); string serializationOfExtend = RxKqlCommonFunctions.ToJson(extendOperator); ExtendOperator hydratedExtendOperator = RxKqlCommonFunctions.ToExtendOperator(serializationOfExtend); Assert.AreEqual(originalString, hydratedExtendOperator.ToString()); }
public void ExtendReplaceFunctionSerializationTest() { string originalString = "extend result = replace(\"@ame.gbl\", \"@microsoft.com\", SubscriptionDetailsData.AccountAdminLiveEmailId)"; ExtendOperator extendOperator = new ExtendOperator(originalString); string serializationOfExtend = RxKqlCommonFunctions.ToJson(extendOperator); ExtendOperator hydratedExtendOperator = RxKqlCommonFunctions.ToExtendOperator(serializationOfExtend); Assert.AreEqual(originalString, hydratedExtendOperator.ToString()); }
public void ExtendScalarFunctionSerializationTest() { List <string> listExtendTestScalarFunctions = new List <string>() { "extend text = strcat(\"Case \", original.id)", "extend text = strlen(\"1234567890\")", "extend text = tostring(123)" }; foreach (string extendedScalarFunction in listExtendTestScalarFunctions) { ExtendOperator extendOperator = new ExtendOperator(extendedScalarFunction); string serializationOfExtend = RxKqlCommonFunctions.ToJson(extendOperator); ExtendOperator hydratedExtendOperator = RxKqlCommonFunctions.ToExtendOperator(serializationOfExtend); Assert.AreEqual(extendedScalarFunction, hydratedExtendOperator.ToString()); } }