Exemplo n.º 1
0
    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);
    }
Exemplo n.º 2
0
    public Task Simple()
    {
        var assembly = typeof(AttributeReaderTests).Assembly;

        return(Verifier.Verify(
                   new
        {
            ProjectDirectory = AttributeReader.GetProjectDirectory(assembly),
            ProjectDirectoryInferred = AttributeReader.GetProjectDirectory(),
            SolutionDirectory = AttributeReader.GetSolutionDirectory(assembly),
            SolutionDirectoryInferred = AttributeReader.GetSolutionDirectory()
        }));
    }
Exemplo n.º 3
0
    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);
    }
Exemplo n.º 4
0
 public Task ProjectDirectory()
 {
     return(Verifier.Verify(AttributeReader.GetProjectDirectory().TrimEnd('\\', '/')));
 }