private void CompareSnapshots( string actualSnapshotSerialized, string savedSnapshotSerialized, SnapshotFullName snapshotFullName, Func <MatchOptions, MatchOptions> matchOptions) { if (savedSnapshotSerialized == null) { _snapshotFileHandler .SaveNewSnapshot(snapshotFullName, actualSnapshotSerialized); return; } try { _snapshotComparer.CompareSnapshots( savedSnapshotSerialized, actualSnapshotSerialized, matchOptions); } catch (Exception) { _snapshotFileHandler .SaveMismatchSnapshot(snapshotFullName, actualSnapshotSerialized); throw; } }
protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); if (ShouldUpdateSnapshot(currentSnapshot, newSnapshot)) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(_snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot) ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }
protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); var areSnapshotsEqual = currentSnapshot != null && _snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot); if (!areSnapshotsEqual && _snapshotUpdateDecider.ShouldUpdateSnapshot()) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(areSnapshotsEqual ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }
public void Compare_SameObject() { var obj = new { v = 1 }; _comparer.CompareSnapshots(obj, obj).Should().BeTrue(); }