public void Compare_ChangedObj_Diff() { var differ = new ReflectionDiffer <ProperertySet>(); var obj1 = new ProperertySet { DoubleValue = 80.2d, StringValue = "string!", IntValue = 100500 }; var obj2 = new ProperertySet { DoubleValue = obj1.DoubleValue, StringValue = obj1.StringValue, IntValue = obj1.IntValue }; obj2.StringValue = "new"; var diff = differ.Compare(obj1, obj2).ToArray(); Assert.AreEqual(1, diff.Length); var diffItem = diff[0]; Assert.AreEqual("StringValue", diffItem.PropertyName); Assert.AreEqual("string!", diffItem.OldValue); Assert.AreEqual("new", diffItem.NewValue); }
public void Compare_SameObj_EmptyCollection() { var differ = new ReflectionDiffer <ProperertySet>(); var obj = new ProperertySet { DoubleValue = 80.2d, StringValue = "string!", IntValue = 100500 }; var diff = differ.Compare(obj, obj); Assert.AreEqual(0, diff.Count()); }
private async void compareVersions_Click(object sender, EventArgs e) { await lockWindowAndRunTask(async() => { string newBranch = getBranch(); bool fetchPrevious = (newBranch == "roblox"); string newApiFilePath = await getApiDumpFilePath(newBranch); string oldApiFilePath = await getApiDumpFilePath("roblox", fetchPrevious); setStatus("Reading the " + (fetchPrevious ? "Previous" : "Production") + " API..."); string oldApiJson = File.ReadAllText(oldApiFilePath); ReflectionDatabase oldApi = ReflectionDatabase.Load(oldApiJson); setStatus("Reading the " + (fetchPrevious ? "Production" : "New") + " API..."); string newApiJson = File.ReadAllText(newApiFilePath); ReflectionDatabase newApi = ReflectionDatabase.Load(newApiJson); setStatus("Comparing APIs..."); ReflectionDiffer differ = new ReflectionDiffer(); string result = differ.CompareDatabases(oldApi, newApi); if (result.Length > 0) { FileInfo info = new FileInfo(newApiFilePath); string directory = info.DirectoryName; string resultPath = Path.Combine(directory, newBranch + "-diff.txt"); writeAndViewFile(resultPath, result); } else { MessageBox.Show("No differences were found!", "Well, this is awkward...", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); }