public void testFieldFormat() { FieldFormat ff1 = FieldFormat.create("<s1><S><F=N><D=Test>"); FieldFormat ff2 = FieldFormat.create("<s1><S><D=Test>"); Assert.IsTrue(ff1.extend(ff2), ff1.extendMessage(ff2)); }
public void TestFloatFieldToString() { var dr = new DataRecord(new TableFormat(FieldFormat.create("data", FieldFormat.FLOAT_FIELD))); dr.setValue(0, 1.1f); Assert.AreEqual("1,1", dr.dataAsString(false, false)); }
public void testDoubleStorage() { FieldFormat ff = FieldFormat.create("<s1><E>"); double d = 123456789.123456D; Assert.AreEqual(d, ff.valueFromString(ff.valueToString(d))); }
public void TestDoubleFieldToString() { var dr = new DataRecord(new TableFormat(FieldFormat.create("data", FieldFormat.DOUBLE_FIELD))); dr.setValue(0, 123456789.123456789d); Assert.AreEqual("123456789,123457", dr.dataAsString(false, false)); }
public void testHashCodesAreEqual() { FieldFormat ff1 = FieldFormat.create("<value><E><A=0.0>"); FieldFormat ff2 = FieldFormat.create("<value><E><A=0.0>"); Assert.AreEqual(ff1.getDefaultValue().GetHashCode(), ff2.getDefaultValue().GetHashCode()); //Assert.AreEqual(ff1.description == null) ? 0 : description.GetHashCode()); //Assert.AreEqual(ff1.editor == null) ? 0 : editor.GetHashCode()); //Assert.AreEqual(ff1.editorOptions == null) ? 0 : editorOptions.GetHashCode()); //Assert.AreEqual(ff1.getIcon().GetHashCode(), ); //result = prime * result + ((group == null) ? 0 : group.GetHashCode()); //result = prime * result + (extendableSelectionValues ? 1231 : 1237); //result = prime * result + ((help == null) ? 0 : help.GetHashCode()); //result = prime * result + (hidden ? 1231 : 1237); //result = prime * result + (inlineData ? 1231 : 1237); //result = prime * result + (keyField ? 1231 : 1237); //result = prime * result + ((name == null) ? 0 : name.GetHashCode()); //result = prime * result + (notReplicated ? 1231 : 1237); //result = prime * result + (nullable ? 1231 : 1237); //result = prime * result + (optional ? 1231 : 1237); //// result = prime * result + (readonly ? 1231 : 1237); //// result = prime * result + (advanced ? 1231 : 1237); //Assert.AreEqual(ff1.getSelectionValues().GetHashCode(), ff2.getSelectionValues().GetHashCode()); //result = prime * result + (transferEncode ? 1231 : 1237); Assert.AreEqual(ff1.getValidators().GetHashCode(), ff2.getValidators().GetHashCode()); Assert.AreEqual(ff1.GetHashCode(), ff2.GetHashCode()); }
static AgentContext() { FOFT_LOGIN.addField("<" + FOF_LOGIN_OWNER + "><S>"); FOFT_LOGIN.addField("<" + FOF_LOGIN_NAME + "><S>"); FOFT_LOGIN.addField("<" + FOF_LOGIN_RESPONSE + "><S>"); FOFT_GET_HISTORY.addField("<" + FOF_GET_HISTORY_VARIABLE + "><S>"); FOFT_GET_HISTORY.addField("<" + FOF_GET_HISTORY_TIMESTAMP + "><D>"); FOFT_GET_HISTORY.addField("<" + FOF_GET_HISTORY_VALUE + "><T>"); FIFT_ACKNOWLEDGE_EVENT.addField("<" + FIF_ACKNOWLEDGE_EVENT_ID + "><L><F=N>"); FIFT_ACKNOWLEDGE_EVENT.addField("<" + FIF_ACKNOWLEDGE_EVENT_DATE + "><D>"); FIFT_ACKNOWLEDGE_EVENT.addField("<" + FIF_ACKNOWLEDGE_EVENT_AUTHOR + "><S><F=N>"); FIFT_ACKNOWLEDGE_EVENT.addField("<" + FIF_ACKNOWLEDGE_EVENT_ACKNOWLEDGEMENT + "><S>"); FIFT_ACKNOWLEDGE_EVENT.addField("<" + FIF_ACKNOWLEDGE_EVENT_EVENT_DATA + "><T>"); FOFT_ASSET.addField("<" + FIELD_ID + "><S><F=HRK>"); FOFT_ASSET.addField("<" + FIELD_DESCRIPTION + "><S><F=R><D=" + Cres.get().getString("description") + ">"); FOFT_ASSET.addField("<" + FIELD_ENABLED + "><B><A=1><D=" + Cres.get().getString("enabled") + ">"); FOFT_ASSET.addField(FieldFormat.create("<" + FIELD_CHILDREN + "><T><F=N><D=" + Cres.get().getString("devNestedAssets") + ">")); FOFT_ASSET.setNamingExpression(AGGREGATE + "({}, \"{env/previous} + ({" + FIELD_ENABLED + "} ? 1 : 0)\", 0) + '/' + {#" + RECORDS + "}"); String reff = FIELD_CHILDREN + "#" + PROPERTY_ENABLED; String exp = "{" + FIELD_ENABLED + "}"; FOFT_ASSET.addBinding(reff, exp); }
public void testFloatStorage() { FieldFormat ff = FieldFormat.create("<s1><F>"); float f = 12345.12f; Assert.AreEqual(f, (float)ff.valueFromString(ff.valueToString(f))); }
public void testClone() { string format = "<s1><S><F=N><A=default><D=Test><S=<desc=default><desc2=val2>><V=<L=1 10>>"; FieldFormat ff = FieldFormat.create(format); FieldFormat cl = (FieldFormat)ff.Clone(); Assert.AreEqual(format, cl.encode(new ClassicEncodingSettings(true))); }
public void testHashCodesDiffer() { FieldFormat ff1 = FieldFormat.create("<value><E><A=0.0>"); FieldFormat ff2 = FieldFormat.create("<value><I><A=0>"); Assert.IsFalse(ff1.GetHashCode() == ff2.GetHashCode()); }
public void TestCreatingString() { var ff = FieldFormat.create("reference", 'S'); Assert.IsNotNull(ff); Assert.AreEqual(ff.getName(), "reference"); Assert.AreEqual(ff.getType(), 'S'); }
public void TestCreatingBoolean() { var ff = FieldFormat.create("name", 'B'); Assert.IsNotNull(ff); Assert.AreEqual(ff.getName(), "name"); Assert.AreEqual(ff.getType(), 'B'); }
public void testHashCodesAreEqual2() { var ff1 = FieldFormat.create("dt", FieldFormat.DATATABLE_FIELD, "dt", new DataTable()); var ff2 = FieldFormat.create("dt", FieldFormat.DATATABLE_FIELD, "dt", new DataTable()); //Assert.AreEqual(ff1.getSelectionValues().GetHashCode(), ff2.getSelectionValues().GetHashCode()); Assert.AreEqual(ff1.getDefaultValue().GetHashCode(), ff2.getDefaultValue().GetHashCode()); Assert.AreEqual(ff1.GetHashCode(), ff2.GetHashCode()); }
static EventUtils() { IntFieldFormat ff = (IntFieldFormat)FieldFormat.create("<" + FIELD_SEVERITY_STATS_LEVEL + "><I><D=" + Cres.get().getString(FIELD_SEVERITY_STATS_LEVEL) + ">"); ff.setSelectionValues(EventLevel.getSelectionValues()); SEVERITY_STATS_FORMAT.addField(ff); SEVERITY_STATS_FORMAT.addField( FieldFormat.create("<" + FIELD_SEVERITY_STATS_NUMBER + "><I><D=" + Cres.get().getString("efEventCount") + ">")); SEVERITY_STATS_FORMAT.addField(FieldFormat.create("<" + FIELD_SEVERITY_STATS_COLOR + "><C><F=H>")); }
protected TableFormat createTestTableFormat() { TableFormat format = new TableFormat(1, 1); FieldFormat ff = FieldFormat.create("name", FieldFormat.STRING_FIELD, "name", "default name"); ff.addValidator(NAME_SYNTAX_VALIDATOR); format.addField(ff); format.addField(FieldFormat.create("dt", FieldFormat.DATATABLE_FIELD, "dt", new DataTable())); format.addField(FieldFormat.create("float", FieldFormat.FLOAT_FIELD, "float", 1.5f)); format.setReorderable(true); return(format); }
public void TestUtfEncoding() { string s = "\uFFFF\u0000\u0123"; DataTable st = new DataTable(new TableFormat(1, 1, FieldFormat.create("f", FieldFormat.STRING_FIELD)), s); string enc = st.encode(); DataTable dt = new DataTable(enc); string d = dt.rec().getString("f"); Assert.AreEqual(s, d); }
public void TestSpecialCharacterEncoding() { string s = string.Empty + DataTableUtils.ELEMENT_START + DataTableUtils.ELEMENT_END + DataTableUtils.ELEMENT_NAME_VALUE_SEPARATOR; s += TransferEncodingHelper.ESCAPE_CHAR + TransferEncodingHelper.SEPARATOR_CHAR; s += AggreGateCommand.CLIENT_COMMAND_SEPARATOR; s += Command.START_CHAR + Command.END_CHAR; DataTable st = new DataTable(new TableFormat(1, 1, FieldFormat.create("f", FieldFormat.STRING_FIELD)), s); string enc = st.encode(); DataTable dt = new DataTable(enc); string d = dt.rec().getString("f"); Assert.AreEqual(s, d); }
public void TestNestedTableEncoding() { string strdata = "test % %% %%% test"; TableFormat tf = new TableFormat(); FieldFormat ff = FieldFormat.create("strfield", FieldFormat.STRING_FIELD); ff.setDefault(strdata); tf.addField(ff); DataTable table = new DataTable(tf, strdata + "value"); DataTable wrapped = table; for (int i = 0; i < 2; i++) { TableFormat wtf = new TableFormat(); FieldFormat wff = FieldFormat.create("dtfield" + i, FieldFormat.DATATABLE_FIELD); wff.setDefault(wrapped); wtf.addField(wff); wrapped = new DataTable(wtf, wrapped); } string encoded = wrapped.encode(false); DataTable restored = new DataTable(encoded, new ClassicEncodingSettings(false), true); Assert.AreEqual(wrapped, restored); }
public void testEquals() { FieldFormat ff1 = FieldFormat.create("<value><I><A=0>"); ff1.addValidator(new LimitsValidator(5, 10)); TableFormat tf1 = ff1.wrap(); tf1.addRecordValidator(new KeyFieldsValidator()); tf1.addTableValidator(new TableKeyFieldsValidator()); FieldFormat ff2 = FieldFormat.create("<value><I><A=0>"); ff2.addValidator(new LimitsValidator(5, 10)); TableFormat tf2 = ff2.wrap(); tf2.addRecordValidator(new KeyFieldsValidator()); tf2.addTableValidator(new TableKeyFieldsValidator()); Assert.AreEqual(tf1, tf2); Assert.AreEqual(tf1.GetHashCode(), tf2.GetHashCode()); }
public void testDefaultValue() { FieldFormat ff1 = FieldFormat.create("<s1><F><A=123.456>"); Assert.IsTrue(Math.Abs(123.456f - (float)ff1.getDefaultValue()) < 0.0000000000001f); }
public void testDefaultDescription() { FieldFormat ff = FieldFormat.create("<theBigValue><S>"); Assert.AreEqual("The Big Value", ff.getDescription()); }