コード例 #1
0
        public static string GetSnapResultMessage(SnapResult result)
        {
            switch (result.Status)
            {
            case SnapResultStatus.SnapshotDoesNotExist:
                var attributeName = nameof(UpdateSnapshotsAttribute).Replace("Attribute", string.Empty);
                var message       = new StringBuilder();
                message.AppendLine($"A snapshot does not exist.{Environment.NewLine}");
                message.AppendLine($"Apply the [{attributeName}] attribute on the " +
                                   $"test method or class and then run the test again to " +
                                   $"create a snapshot.");
                return(message.ToString());

            case SnapResultStatus.SnapshotsMatch:
                return("Snapshots Match.");

            case SnapResultStatus.SnapshotsDoNotMatch:
                return(JsonDiffGenerator.GetDiffMessage(result.OldSnapshot, result.NewSnapshot));

            case SnapResultStatus.SnapshotUpdated:
                return("Snapshot was updated.");

            default:
                return(string.Empty);
            }
        }
コード例 #2
0
        public void AssertSnapshot(SnapResult snapResult)
        {
            switch (snapResult.Status)
            {
            case SnapResultStatus.SnapshotDoesNotExist:
                throw new SnapshotDoesNotExistException(snapResult);

            case SnapResultStatus.SnapshotsDoNotMatch:
                throw new SnapshotsDoNotMatchException(snapResult);

            case SnapResultStatus.SnapshotUpdated:
            case SnapResultStatus.SnapshotsMatch:
            default:
                return;
            }
        }
コード例 #3
0
ファイル: Messages.cs プロジェクト: zubivan/Snapper
        public static string GetSnapResultMessage(SnapResult result)
        {
            switch (result.Status)
            {
            case SnapResultStatus.SnapshotDoesNotExist:
                var message = new StringBuilder();
                message.AppendLine($"A snapshot does not exist.{Environment.NewLine}");
                message.AppendLine("Run the test outside of a CI environment to create a snapshot.");
                return(message.ToString());

            case SnapResultStatus.SnapshotsMatch:
                return("Snapshots Match.");

            case SnapResultStatus.SnapshotsDoNotMatch:
                return(JsonDiffGenerator.GetDiffMessage(result.OldSnapshot, result.NewSnapshot));

            case SnapResultStatus.SnapshotUpdated:
                return("Snapshot was updated.");

            default:
                return(string.Empty);
            }
        }