public async Task PartialNamedTuple() { var exception = await Assert.ThrowsAsync <Exception>(() => Verifier.Verify(() => MethodWithPartialNamedTuple())); FileNameBuilder.ClearPrefixList(); await Verifier.Verify(exception.Message); }
public async Task Instance() { VerifySettings settings = new(); settings.UseStringComparer(Compare); await Verifier.Verify("TheText", settings); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("thetext", settings); }
public async Task Static() { VerifierSettings.RegisterComparer("staticComparerExt", Compare); VerifySettings settings = new(); settings.UseExtension("staticComparerExt"); await Verifier.Verify("TheText", settings); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("thetext", settings); }
static async Task RunTest( string extension, Func <object> initialTarget, Func <object> secondTarget, bool hasMatchingDiffTool, bool hasExistingReceived, bool autoVerify, VerifySettings settings, string uniqueTestName) { settings.UseExtension(extension); if (autoVerify) { settings.AutoVerify(); } var projectDirectory = AttributeReader.GetProjectDirectory(); var prefix = Path.Combine(projectDirectory, uniqueTestName); var danglingFile = Path.Combine(projectDirectory, $"{prefix}.01.verified.{extension}"); FilePair file = new(extension, prefix); DeleteAll(danglingFile, file.Verified, file.Received); await File.WriteAllTextAsync(danglingFile, ""); if (hasExistingReceived) { await File.WriteAllTextAsync(file.Received, ""); } FileNameBuilder.ClearPrefixList(); await InitialVerify(initialTarget, hasMatchingDiffTool, settings, file); if (!autoVerify) { RunClipboardCommand(); } AssertNotExists(danglingFile); FileNameBuilder.ClearPrefixList(); await ReVerify(initialTarget, settings, file); FileNameBuilder.ClearPrefixList(); await InitialVerify(secondTarget, hasMatchingDiffTool, settings, file); if (!autoVerify) { RunClipboardCommand(); } FileNameBuilder.ClearPrefixList(); await ReVerify(secondTarget, settings, file); }
public async Task Static() { EmptyFiles.Extensions.AddTextExtension("staticComparerExt"); VerifierSettings.RegisterStringComparer("staticComparerExt", Compare); var settings = new VerifySettings(); settings.UseExtension("staticComparerExt"); await Verifier.Verify("TheText", settings); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("thetext", settings); }
public async Task Simple() { var settings = new VerifySettings(); settings.UseMethodName("Foo"); settings.DisableDiff(); await Verifier.Verify( @"The before text", settings) .AutoVerify(); FileNameBuilder.ClearPrefixList(); await Verifier.ThrowsTask(() => Verifier.Verify( @"The after text", settings)) .ScrubLinesContaining("DiffEngineTray"); }
public async Task StringWithDifferingNewline() { var fullPath = Path.GetFullPath("../../../Tests.StringWithDifferingNewline.verified.txt"); File.Delete(fullPath); File.WriteAllText(fullPath, "a\r\nb"); await Verifier.Verify("a\r\nb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\rb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\nb"); FileNameBuilder.ClearPrefixList(); File.Delete(fullPath); File.WriteAllText(fullPath, "a\nb"); await Verifier.Verify("a\r\nb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\rb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\nb"); FileNameBuilder.ClearPrefixList(); File.Delete(fullPath); File.WriteAllText(fullPath, "a\rb"); await Verifier.Verify("a\r\nb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\rb"); FileNameBuilder.ClearPrefixList(); await Verifier.Verify("a\nb"); }
public Task Test( bool run, bool runG, bool config, bool configG, bool runVersion, bool runVersionG, bool method, bool type, bool dir) { var sharedNamer = VerifierSettings.SharedNamer; sharedNamer.UniqueForAssemblyConfiguration = false; sharedNamer.UniqueForRuntime = false; sharedNamer.UniqueForRuntimeAndVersion = false; var directory = Path.Combine(Path.GetTempPath(), "VerifyNamer"); if (Directory.Exists(directory)) { Directory.Delete(directory, true); } Directory.CreateDirectory(directory); VerifySettings settings = new(); if (run) { settings.UniqueForRuntime(); } if (runG) { VerifierSettings.UniqueForRuntime(); } if (config) { settings.UniqueForAssemblyConfiguration(); } if (configG) { VerifierSettings.UniqueForAssemblyConfiguration(); } if (runVersion) { settings.UniqueForRuntimeAndVersion(); } if (runVersionG) { VerifierSettings.UniqueForRuntimeAndVersion(); } if (method) { settings.UseMethodName("CustomMethod"); } if (type) { settings.UseMethodName("CustomType"); } if (dir) { settings.UseDirectory("customDir"); } var builder = Builder(directory, settings); var fileNames = builder.GetFileNames("txt"); var fileNamesWithIndex = builder.GetFileNames("txt", 2); File.WriteAllText(fileNames.Received, ""); File.WriteAllText(fileNames.Verified, ""); File.WriteAllText(fileNamesWithIndex.Received, ""); File.WriteAllText(fileNamesWithIndex.Verified, ""); FileNameBuilder.ClearPrefixList(); builder = Builder(directory, settings); var receivedFiles = builder.ReceivedFiles.OrderBy(x => x); var verifiedFiles = builder.VerifiedFiles.OrderBy(x => x); FileNameBuilder.ClearPrefixList(); return(Verifier.Verify(new { fileNames, fileNamesWithIndex, receivedFiles, verifiedFiles }) .UseParameters( run, runG, config, configG, runVersion, runVersionG, method, type, dir) .UseMethodName("_") .UseTypeName("_") .AddScrubber(_ => _.Replace('/', '\\'))); }
public async Task Split( bool hasExistingReceived, bool autoVerify) { TypeToSplit initialTarget = new("info1", "value1", "value2"); TypeToSplit secondTarget = new("info2", "value1.1", "value2.1"); var settings = new VerifySettings(); if (autoVerify) { settings.AutoVerify(); } var method = GetType().GetMethod("Split") !; var concat = ParameterBuilder.Concat(method, new object[] { hasExistingReceived, autoVerify }); var uniqueTestName = $"Tests.Split_{concat}"; settings.UseParameters(hasExistingReceived, autoVerify); var prefix = Path.Combine(AttributeReader.GetProjectDirectory(), $"{uniqueTestName}."); var danglingFile = $"{prefix}03.verified.txt"; FilePair file0 = new("txt", $"{prefix}00"); FilePair file1 = new("txt", $"{prefix}01"); FilePair file2 = new("txt", $"{prefix}02"); DeleteAll(danglingFile, file0.Received, file0.Verified, file1.Verified, file1.Received, file2.Verified, file2.Received); await File.WriteAllTextAsync(danglingFile, ""); if (hasExistingReceived) { await File.WriteAllTextAsync(file0.Received, ""); await File.WriteAllTextAsync(file1.Received, ""); await File.WriteAllTextAsync(file2.Received, ""); } FileNameBuilder.ClearPrefixList(); await InitialVerifySplit(initialTarget, true, settings, file0, file1, file2); if (!autoVerify) { RunClipboardCommand(); } AssertNotExists(danglingFile); FileNameBuilder.ClearPrefixList(); await ReVerifySplit(initialTarget, settings, file0, file1, file2); FileNameBuilder.ClearPrefixList(); await InitialVerifySplit(secondTarget, true, settings, file0, file1, file2); if (!autoVerify) { RunClipboardCommand(); } FileNameBuilder.ClearPrefixList(); await ReVerifySplit(secondTarget, settings, file0, file1, file2); }
public Result Run( bool run, bool runG, bool config, bool configG, bool runVersion, bool runVersionG, bool arch, bool archG, bool os, bool osG, bool method, bool type, bool dir) { var sharedNamer = VerifierSettings.SharedNamer; sharedNamer.UniqueForAssemblyConfiguration = false; sharedNamer.UniqueForRuntime = false; sharedNamer.UniqueForRuntimeAndVersion = false; sharedNamer.UniqueForArchitecture = false; sharedNamer.UniqueForOSPlatform = false; var directory = Path.Combine(Path.GetTempPath(), "VerifyNamer"); if (Directory.Exists(directory)) { Directory.Delete(directory, true); } Directory.CreateDirectory(directory); var settings = new VerifySettings(); if (run) { settings.UniqueForRuntime(); } if (runG) { VerifierSettings.UniqueForRuntime(); } if (config) { settings.UniqueForAssemblyConfiguration(); } if (configG) { VerifierSettings.UniqueForAssemblyConfiguration(); } if (runVersion) { settings.UniqueForRuntimeAndVersion(); } if (runVersionG) { VerifierSettings.UniqueForRuntimeAndVersion(); } if (arch) { settings.UniqueForArchitecture(); } if (archG) { VerifierSettings.UniqueForArchitecture(); } if (os) { settings.UniqueForOSPlatform(); } if (osG) { VerifierSettings.UniqueForOSPlatform(); } if (method) { settings.UseMethodName("CustomMethod"); } if (type) { settings.UseMethodName("CustomType"); } if (dir) { settings.UseDirectory("customDir"); } var builder = Builder(directory, settings); var fileNames = builder.GetFileNames("txt"); var fileNamesWithIndex = builder.GetFileNames("txt", 2); File.WriteAllText(fileNames.Received, ""); File.WriteAllText(fileNames.Verified, ""); File.WriteAllText(fileNamesWithIndex.Received, ""); File.WriteAllText(fileNamesWithIndex.Verified, ""); FileNameBuilder.ClearPrefixList(); builder = Builder(directory, settings); var receivedFiles = builder.ReceivedFiles.OrderBy(x => x); var verifiedFiles = builder.VerifiedFiles.OrderBy(x => x); FileNameBuilder.ClearPrefixList(); return(new() { FileNames = fileNames, FileNamesWithIndex = fileNamesWithIndex, ReceivedFiles = receivedFiles, VerifiedFiles = verifiedFiles }); }