Exemplo n.º 1
0
 /// <summary>
 /// Creates a json snapshot of the given object and compares it with the
 /// already existing snapshot of the test.
 /// If no snapshot exists, a new snapshot will be created from the current result
 /// and saved under a certain file path, which will shown within the test message.
 /// </summary>
 /// <param name="currentResult">The object to match.</param>
 /// <param name="snapshotFullName">
 /// The full name of a snapshot with folder and file name.</param>
 /// <param name="matchOptions">
 /// Additional compare actions, which can be applied during the snapshot comparison.
 /// </param>
 public static void Match(
     object currentResult,
     SnapshotFullName snapshotFullName,
     Func <MatchOptions, MatchOptions> matchOptions = null)
 {
     Snapshooter.AssertSnapshot(currentResult, snapshotFullName, matchOptions);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a json snapshot of the given object and compares it with the
 /// already existing snapshot of the test.
 /// If no snapshot exists, a new snapshot will be created from the current result
 /// and saved under a certain file path, which will shown within the test message.
 /// </summary>
 /// <param name="currentResult">The object to match.</param>
 /// <param name="matchOptions">
 /// Additional compare actions, which can be applied during the snapshot comparison
 /// </param>
 public static void Match(
     object currentResult,
     Func <MatchOptions, MatchOptions> matchOptions = null)
 {
     Snapshooter.AssertSnapshot(currentResult, FullName(), matchOptions);
     _snapshotName = new AsyncLocal <SnapshotFullName>();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Matches the current result/object with the actual snapshot of the test. If
        /// no snapshot exists, a new snapshot will be created from the current result
        /// and saved under a certain file path, which will shown in the assert exception.
        /// </summary>
        /// <typeparam name="T">The type of the result/object to match.</typeparam>
        /// <param name="currentResult">The object to match.</param>
        ///  /// <param name="snapshotName">
        /// The name of the snapshot. If not set, then the snapshotname
        /// will be evaluated automatically.
        /// </param>
        /// <param name="snapshotNameExtension">
        /// The snapshot name extension will extend the generated snapshot name with
        /// this given extensions. It can be used to make a snapshot name even more
        /// specific.
        /// Example:
        /// Generated Snapshotname = 'NumberAdditionTest'
        /// Snapshot name extension = '5', '6', 'Result', '11'
        /// Result: 'NumberAdditionTest_5_6_Result_11'
        /// </param>
        /// <param name="matchOptions">
        /// Additional compare actions, which can be applied during the comparison
        /// </param>
        public static void Match(object currentResult,
                                 string snapshotName,
                                 SnapshotNameExtension snapshotNameExtension,
                                 Func <MatchOptions, MatchOptions> matchOptions = null)
        {
            SnapshotFullName snapshotFullName = FullName(snapshotName, snapshotNameExtension);

            Snapshooter.AssertSnapshot(currentResult, snapshotFullName, matchOptions);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a json snapshot of the given object and compares it with the
 /// already existing snapshot of the test.
 /// If no snapshot exists, a new snapshot will be created from the current result
 /// and saved under a certain file path, which will shown within the test message.
 /// </summary>
 /// <param name="currentResult">The object to match.</param>
 /// <param name="snapshotFullName">
 /// The full name of a snapshot with folder and file name.</param>
 /// <param name="matchOptions">
 /// Additional compare actions, which can be applied during the snapshot comparison.
 /// </param>
 public static void Match(
     object currentResult,
     SnapshotFullName snapshotFullName,
     Func <MatchOptions, MatchOptions> matchOptions = null)
 {
     try
     {
         Snapshooter.AssertSnapshot(currentResult, snapshotFullName, matchOptions);
     }
     finally
     {
         _snapshotName = new AsyncLocal <SnapshotFullName>();
     }
 }