private void CompareFormatted(ComparerControlViewModel vm, object parameter) { ErrorMessage = null; string error; string formattedJsonl = JsonFormatter.FormatIfPossible(vm.Json1Content, out error); if (error != null) { ErrorMessage = $"Invalid JSON in \"{vm.Json1Name}\". {error}"; return; } string formattedJson2 = JsonFormatter.FormatIfPossible(vm.Json2Content, out error); if (error != null) { ErrorMessage = $"Invalid JSON in \"{vm.Json2Name}\". {error}"; return; } try { JsonComparer.Compare(formattedJsonl, vm.Json1Name, formattedJson2, vm.Json2Name); } catch (Exception e) { ErrorMessage = $"Failed to compare. {e.Message}"; } }
public void EventsTransformationShouldNotSpoilData(JObject source) { var @event = LogEventConverter.Convert(source); if (@event.GetType() == typeof(LogEvent)) { Assert.Pass("Automatic pass for non-typed events"); } if (@event is FsdJump || @event is Location || @event is Docked) { source.Remove("StationFaction"); source.Remove("SystemFaction"); source.Remove("FactionState"); } // TODO: return those fields to objects var serialized = JObject.FromObject(@event, Converter.Serializer); if (@event is Scan) { source.Remove("Parents"); // TODO: find a way to serialize that structure } Assert.IsEmpty(JsonComparer.Compare(@event.Event, source, serialized)); // This assert should never trigger - if it triggers means there's an error in comparison code Assert.IsTrue(JToken.DeepEquals(source, serialized), "Json objects before/after serialization should be 'DeepEqual'"); }
private void CompareFormatted(ComparerTabViewModel vm, object parameter) { string formattedJsonl; string formattedJson2; try { formattedJsonl = Format(vm.Json1Content, vm.Json1Name); formattedJson2 = Format(vm.Json2Content, vm.Json2Name); } catch (Exception e) { Message = $" {e.Message} Correct JSON or compare without preliminary formatting. "; return; } try { JsonComparer.Compare(formattedJsonl, vm.Json1Name, formattedJson2, vm.Json2Name); Message = ""; } catch (Exception e) { Message = $" Failed to compare JSONs. {e.Message} "; } }
private void Compare(ComparerTabViewModel vm, object parameter) { try { JsonComparer.Compare(vm.Json1Content, vm.Json1Name, vm.Json2Content, vm.Json2Name); } catch (Exception e) { MessageBox.Show("Error while comparing JSONs: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void ExecuteCompare() { if (!CanExecuteCompare()) { throw new InvalidOperationException(); } Differences = JsonComparer .Compare(LeftVM.First().Model, RightVM.First().Model) .Select(d => new DifferenceViewModel(d, _map[d.LeftNode].First(), _map[d.RightNode].First())) .ToList(); }
private void Compare(ComparerControlViewModel vm, object parameter) { ErrorMessage = null; try { JsonComparer.Compare(vm.Json1Content, vm.Json1Name, vm.Json2Content, vm.Json2Name); } catch (Exception e) { ErrorMessage = $"Failed to compare. {e.Message}"; } }
private void Compare(ComparerTabViewModel vm, object parameter) { try { JsonComparer.Compare(vm.Json1Content, vm.Json1Name, vm.Json2Content, vm.Json2Name); Message = ""; } catch (Exception e) { Message = $"Failed to compare JSONs. {e.Message} "; } }
private void CompareFormatted(ComparerTabViewModel vm, object parameter) { try { var formattedJsonl = JsonFormatter.Format(vm.Json1Content, vm.Json1Name); var formattedJson2 = JsonFormatter.Format(vm.Json2Content, vm.Json2Name); JsonComparer.Compare(formattedJsonl, vm.Json1Name, formattedJson2, vm.Json2Name); } catch (Exception e) { MessageBox.Show("Error while comparing formatted JSONs: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void EventsTransformationShouldNotSpoilData(LogEvent e) { if (e.GetType() == typeof(LogEvent)) { Assert.Fail("This test only supports typed events"); } var serialized = JObject.FromObject(e, Converter.Serializer); if (e is Scan) { e.Raw.Remove("Parents"); // TODO: find a way to serialize that structure } Assert.IsEmpty(JsonComparer.Compare(e.Event, e.Raw, serialized)); // This assert should never trigger - if it triggers means there's an error in comparison code Assert.IsTrue(JToken.DeepEquals(e.Raw, serialized), "Json objects before/after serialization should be 'DeepEqual'"); }
public void EventsTransformationShouldNotSpoilData(JObject source) { var @event = JournalEventConverter.Convert(source); if (@event.GetType() == typeof(JournalEvent)) { Assert.Inconclusive("Event is not typed"); } var serialized = JObject.FromObject(@event, Converter.Serializer); if (@event is Scan) { source.Remove("Parents"); // TODO: find a way to serialize that structure } var diffs = JsonComparer.Compare(@event.Event, source, serialized); Assert.IsEmpty(diffs); }
public void WhenComparingTwoEmptyJsonObject_ReturnNoError() { var actualErrors = _jsonComparer.Compare("{}", "{}"); actualErrors.Should().BeEmpty(); }