public void Iteration_GetSet_OK() { Dictionary <string, string[]> IterationSets = new Dictionary <string, string[]>(); IterationSets.Add("List", new string[] { "A", "B", "C" }); IterationSets.Add("Numbers01", new string[] { "10", "9", "8", "7", "6", "5", "4", "3", "2", "1", "0" }); IterationSets.Add("Numbers02", new string[] { "250", "255", "260", "265", "270", "275", "280" }); Iteration iter = new Iteration(); iter.AddListItems("List", new List <string>(IterationSets["List"])); iter.AddNumberRange("Numbers01", 10, -1, 0, Iteration.EndValueEval.Inclusive); iter.AddNumberSequence("Numbers02", 250, 5, 7); string serialized = ObjectXMLSerializer <Iteration> .CreateDocumentFormat(iter); Iteration iterCloned = ObjectXMLSerializer <Iteration> .CreateObjectFormat(serialized); Assert.AreEqual(iter.IterationItems.Count, iterCloned.IterationItems.Count, "Iteration item count mismatch"); foreach (int key in iter.IterationItems.Keys) { Assert.AreEqual( iter.IterationItems[key].Name, iterCloned.IterationItems[key].Name, "Iteration item name mismatch for key " + key.ToString()); Assert.AreEqual( iter.IterationItems[key].IterationValues.Count, iterCloned.IterationItems[key].IterationValues.Count, "Iteration item count mismatch for key " + key.ToString()); } Assert.AreEqual(iter.TotalIterationCount, iterCloned.TotalIterationCount, "Total count mismatch"); }
public void SerializableJson_ObjectToContainerToObject_ImplicitAlgorithm() { Support.MyDataSet original = MakeMyDataSet(); int setCount = original.coll.Count; string password = "******"; string salt = "JustAsEasy"; string rawContent = ObjectXMLSerializer <Support.MyDataSet> .CreateDocumentFormat(original); //int rawContentLength = rawContent.Length; string transitContent = ObjectXMLSerializer <Support.MyDataSet> .CreateTransitContainerForObject(original, password, salt); //int transitContentLength = transitContent.Length; Support.MyDataSet result = ObjectXMLSerializer <Support.MyDataSet> .CreateObjectFromTransitContainer(transitContent, password, salt); Assert.AreEqual(result.s1, original.s1, "s1 not same"); Assert.AreEqual(result.i16, original.i16, "i16 not same"); Assert.AreEqual(result.i32, original.i32, "i32 not same"); Assert.AreEqual(result.i64, original.i64, "i64 not same"); Assert.AreEqual(result.Timestamp, original.Timestamp, "Timestamp not same"); Assert.AreEqual(result.coll.Count, setCount, "coll.Count not " + setCount.ToString()); Assert.AreEqual(result.coll.Count, original.coll.Count, "coll.Count not same"); for (int index = 0; index < setCount; index++) { Assert.AreEqual(result.coll[index], original.coll[index], "coll[] not same at index " + index.ToString()); } }
public frmSerializableDictionary() { InitializeComponent(); fuses.Add("porch light", new Fuse( Fuse.FuseBehavior.Hits_Only, 5, 0, new TimeSpan(0, 0, 60, 0), false)); fuses.Add("refrigerator", new Fuse( Fuse.FuseBehavior.Volume_Only, 0, 10000, new TimeSpan(0, 0, 60, 0), false)); fuses.Add("tv", new Fuse( Fuse.FuseBehavior.Hits_OR_Volume, 2, 100, new TimeSpan(0, 2, 0, 0), false)); fuses["tv"].RecordFuseEvent(65); fuses["tv"].RecordFuseEvent(44); fuses["tv"].RecordFuseEvent(17); this.txtSerializedXML.Text = ObjectXMLSerializer <SerializableDictionary <string, Fuse> > .CreateDocumentFormat(fuses); }
public bool CopyConfigToClipboard() { bool result = false; if (this.lvwConfigSet.SelectedIndices.Count > 0) { WeedKillerConfigSet cs = new WeedKillerConfigSet(); for (int i = 0; i < this.lvwConfigSet.SelectedIndices.Count; i++) { cs.ConfigSet.Add((WeedKillerConfig)this.lvwConfigSet.Items[this.lvwConfigSet.SelectedIndices[i]].Tag); } Clipboard.SetText(ObjectXMLSerializer <WeedKillerConfigSet> .CreateDocumentFormat(cs)); result = true; } else { MessageBox.Show("You must select one or more configuration items to copy", "Nothing to do", MessageBoxButtons.OK, MessageBoxIcon.Hand); } return(result); }