Ejemplo n.º 1
0
 public ApprovedTests()
 {
     settings = new VerifySettings();
     settings.UniqueForRuntime();
     settings.UniqueForAssemblyConfiguration();
     settings.AddScrubber(v => v.Replace("InternalBase.", string.Empty));
     settings.AddScrubber(v => v.Replace("AssemblyBase.", string.Empty));
     settings.AddScrubber(v => v.Replace("ExternalBase.", string.Empty));
 }
Ejemplo n.º 2
0
    public Task Usage()
    {
        var settings = new VerifySettings(classLevelSettings);

        settings.AddScrubber(s => s.Replace("Two", "B"));
        return(Verify("One Two Three", settings));
    }
Ejemplo n.º 3
0
    public Task ExampleNonDefaults()
    {
        var person = new Person
        {
            Id         = new Guid("ebced679-45d3-4653-8791-3d969c4a986c"),
            Title      = Title.Mr,
            GivenNames = "John",
            FamilyName = "Smith",
            Spouse     = "Jill",
            Children   = new List <string> {
                "Sam", "Mary"
            },
            Address = new Address
            {
                Street  = "1 Puddle Lane",
                Country = "USA"
            }
        };

        var settings = new VerifySettings();

        settings.ModifySerialization(_ =>
        {
            _.DontScrubDateTimes();
            _.DontIgnoreFalse();
            _.DontScrubGuids();
            _.DontIgnoreEmptyCollections();
        });
        settings.AddScrubber(s => s.Replace("Lane", "Street"));
        return(Verify(person, settings));
    }
Ejemplo n.º 4
0
    public Task ExtensionAwareScrubbers()
    {
        var settings = new VerifySettings();

        settings.UseExtension("html");
        settings.AddScrubber("html", builder => builder.Replace("a", "b"));
        return(Verifier.Verify("a", settings));
    }
Ejemplo n.º 5
0
    public Task ScrubberWithBadNewLine()
    {
        var settings = new VerifySettings();

        settings.AddScrubber(s =>
        {
            s.AppendLine("b");
            s.AppendLine("c");
        });
        return(Verify("a", settings));
    }
Ejemplo n.º 6
0
    public Task ScrubberAppliedAfterJsonSerialization()
    {
        var target = new ToBeScrubbed
        {
            RowVersion = "0x00000000000007D3"
        };

        var settings = new VerifySettings();

        settings.AddScrubber(
            s => s.Replace("0x00000000000007D3", "TheRowVersion"));
        return(Verifier.Verify(target, settings));
    }
Ejemplo n.º 7
0
    public Task AfterSerialization()
    {
        var target = new ToBeScrubbed
        {
            RowVersion = "7D3"
        };

        var settings = new VerifySettings();

        settings.AddScrubber(
            input => input.Replace("7D3", "TheRowVersion"));
        return(Verifier.Verify(target, settings));
    }
    protected static VerifySettings CreateVerifySettings(
        GeneratorTestInput yamlFile,
        ApiProjectOptions apiOptions)
    {
        ArgumentNullException.ThrowIfNull(yamlFile);

        var settings = new VerifySettings();

        settings.UseDirectory(yamlFile.TestDirectory);
        settings.UseFileName(yamlFile.TestName);
        settings.UseExtension("cs");
        settings.AddScrubber(input => input.Replace(apiOptions.ToolVersion.ToString(), "x.x.x.x"));
        return(settings);
    }
Ejemplo n.º 9
0
    void List()
    {
        var verifySettings = new VerifySettings();

        #region ScrubLines

        verifySettings.ScrubLines(line => line.Contains("text"));

        #endregion

        #region ScrubLinesContaining

        verifySettings.ScrubLinesContaining("text1", "text2");

        #endregion

        #region ScrubLinesContainingOrdinal

        verifySettings.ScrubLinesContaining(StringComparison.Ordinal, "text1", "text2");

        #endregion

        #region ScrubLinesWithReplace

        verifySettings.ScrubLinesWithReplace(line => line.ToUpper());

        #endregion

        #region ScrubMachineName

        verifySettings.ScrubMachineName();

        #endregion

        #region AddScrubber

        verifySettings.AddScrubber(fullText => fullText.Remove(0, 100));

        #endregion
    }
Ejemplo n.º 10
0
    public async Task AppendFileAsSnippet()
    {
        var temp = Path.GetTempFileName().ToLowerInvariant();

        try
        {
            File.WriteAllText(temp, "Foo");
            var snippets = new List <Snippet>();
            snippets.AppendFileAsSnippet(temp);
            var settings = new VerifySettings();
            settings.AddScrubber(x =>
            {
                var nameWithoutExtension = Path.GetFileNameWithoutExtension(temp);
                x.Replace(temp, "FilePath.txt");
                x.Replace(nameWithoutExtension, "File");
            });
            await Verifier.Verify(snippets, settings);
        }
        finally
        {
            File.Delete(temp);
        }
    }
Ejemplo n.º 11
0
    public async Task AppendFileAsSnippet()
    {
        var temp = Path.GetTempFileName();

        try
        {
            File.WriteAllText(temp, "Foo");
            var snippets = new List <Snippet>();
            snippets.AppendFileAsSnippet(temp);
            var settings = new VerifySettings();
            settings.AddScrubber(x =>
            {
                var nameWithoutExtension = Path.GetFileNameWithoutExtension(temp);
                return(x
                       .Replace(temp, "FilePath.txt")
                       .Replace(nameWithoutExtension, "File", StringComparison.OrdinalIgnoreCase));
            });
            await Verify(snippets, settings);
        }
        finally
        {
            File.Delete(temp);
        }
    }
Ejemplo n.º 12
0
 public ScrubberLevelsSample(ITestOutputHelper output) :
     base(output)
 {
     classLevelSettings = new VerifySettings();
     classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
 }
Ejemplo n.º 13
0
 public ScrubberLevelsSample()
 {
     classLevelSettings = new VerifySettings();
     classLevelSettings.AddScrubber(s => s.Replace("Three", "C"));
 }
 public static void PrettyPrintHtml(
     this VerifySettings settings)
 {
     settings.AddScrubber("html", Scrubber);
     settings.AddScrubber("htm", Scrubber);
 }