public void SimpleValueReplacement() { RepositoryInfoHub.Flush(); var replacementTokenXmlHandler = new ReplacementTokenXmlHandler(); var attributes = new Dictionary<string, string>(); const string constantTokenValue = "constant text"; attributes.Add("TokenName", "Foo"); attributes.Add("Value", constantTokenValue); replacementTokenXmlHandler.ProcessStartElement("ReplacementToken", attributes); Assert.That(RepositoryInfoHub.Instance.ParseTokens("#Foo#"), Is.EqualTo(constantTokenValue)); }
public void RegExReplacementWithExistingTokenAsValue() { RepositoryInfoHub.Flush(); var replacementTokenXmlHandler = new ReplacementTokenXmlHandler(); var attributes = new Dictionary<string, string>(); attributes.Add("TokenName", "Foo"); attributes.Add("Value", "#logmessage#"); attributes.Add("RegExPattern", @"\[Review #(\d+)\]"); replacementTokenXmlHandler.ProcessStartElement("ReplacementToken", attributes); var repoChangeInfo = MockRepository.GenerateStub<IRepoChangeInfo>(); repoChangeInfo.Expect(x => x.LogMessage).Return("This commit updates [Review #123] by fixing stuff"); repoChangeInfo.Expect(x => x.AffectedItems).Return(new List<IRepoAffectedItem>()); RepositoryInfoHub.Instance.RepoChangeInfo = repoChangeInfo; Assert.That(RepositoryInfoHub.Instance.ParseTokens("#Foo#"), Is.EqualTo("123")); }