public void SecretsAreRemovedFromText() { var secretTracker = new SecretTracker(); secretTracker.AddSecret("secret"); var redacted1 = secretTracker.FilterString("This is a secret."); secretTracker.AddSecret("is"); var redacted2 = secretTracker.FilterString("This is a secret."); Assert.AreEqual($"This is a {Redacted}.", redacted1); Assert.AreEqual($"Th{Redacted} {Redacted} a {Redacted}.", redacted2); }
public void SecretsAreReplacedInAnOrderThatIsDeterminedBySubstringContainment() { var secretTracker1 = new SecretTracker(); secretTracker1.AddSecret("defghijkl"); secretTracker1.AddSecret("abc"); secretTracker1.AddSecret("ghi"); secretTracker1.AddSecret("d"); var redacted1 = secretTracker1.FilterString("abcdefghijklmno abc-def-ghi-jkl-mno"); var secretTracker2 = new SecretTracker(); secretTracker2.AddSecret("a"); secretTracker2.AddSecret("d"); secretTracker2.AddSecret("g"); secretTracker2.AddSecret("ghi"); secretTracker2.AddSecret("abc"); secretTracker2.AddSecret("defghijkl"); var redacted2 = secretTracker2.FilterString("abcdefghijklmno abc-def-ghi-jkl-mno"); var secretTracker3 = new SecretTracker(); secretTracker3.AddSecret("g"); secretTracker3.AddSecret("defghijkl"); secretTracker3.AddSecret("abc"); secretTracker3.AddSecret("d"); secretTracker3.AddSecret("ghi"); secretTracker3.AddSecret("a"); var redacted3 = secretTracker3.FilterString("abcdefghijklmno abc-def-ghi-jkl-mno"); Assert.AreEqual($"{Redacted}{Redacted}mno {Redacted}-{Redacted}ef-{Redacted}-jkl-mno", redacted1); Assert.AreEqual($"{Redacted}{Redacted}mno {Redacted}-{Redacted}ef-{Redacted}-jkl-mno", redacted2); Assert.AreEqual($"{Redacted}{Redacted}mno {Redacted}-{Redacted}ef-{Redacted}-jkl-mno", redacted3); }