public void Test_Issue4() { var strings = new [] { "hello", "there" }; var hron = HRONSerializer.ObjectAsString(strings); List <string> resultsStrings; HRONObjectParseError[] errors; var result = HRONSerializer.TryParseObject( 100, hron.ReadLines(), out resultsStrings, out errors ); TestFor.Equality(true, result, "TryParseObject should succeed"); if (TestFor.Equality(strings.Length, resultsStrings.Count, "The length of expected and result sets should be the same")) { for (var iter = 0; iter < strings.Length; ++iter) { TestFor.Equality(strings[iter], resultsStrings[iter], "The result set should have the same value as the expected set: {0}".FormatWith(iter)); } } }
public static TableVersion GetTargetVersion( this SqlConnection conn, string tableName, out string targetStatePath ) { if (!SyncStateDirectory.Exists) { SyncStateDirectory.Create(); } targetStatePath = Path.Combine( SyncStateDirectory.FullName, Uri.EscapeDataString( string.Concat( conn.DataSource, "_", conn.Database, "_", tableName, ".hron" ) ) ); TableVersion targetVersion; HRONObjectParseError[] errors; if ( File.Exists(targetStatePath) && HRONSerializer.TryParseObject( 0, File.ReadAllText(targetStatePath, Encoding.UTF8).ReadLines(), out targetVersion, out errors )) { return(targetVersion); } var tableVersion = new TableVersion { CurrentVersion = -1, MinValidVersion = -1 }; File.WriteAllText( targetStatePath, HRONSerializer.ObjectAsString( tableVersion ), Encoding.UTF8 ); return(tableVersion); }
public static bool TryLoad(string jobPath, out SyncJob syncJob) { syncJob = null; HRONObjectParseError[] errors; return( File.Exists(jobPath) && HRONSerializer.TryParseObject( 0, File.ReadAllText(jobPath, Encoding.UTF8).ReadLines(), out syncJob, out errors ) ); }
public void Test_TryParseObject() { var lines = s_test2_hron.ReadLines().ToArray(); Config config; HRONObjectParseError[] errors; var result = HRONSerializer.TryParseObject(int.MaxValue, lines, out config, out errors); if (TestFor.Equality(true, result, "HRON should be parsed successfully")) { var value = HRONSerializer.ObjectAsString(config); TestFor.Equality( s_test2_hron, value, "HRON after deserialize/serialize to object should be identical to test case" ); } }