public void Regex_MatchesForFile() { VersionFileUpdater sut = new VersionFileUpdater(); var rx = sut.GetRegex("AssemblyInformationalVersion"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0.0.0\")]"), "1 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0.0\")]"), "2 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0.0\")]"), "3 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"0\")]"), "4 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion(\"\")]"), "5 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyInformationalVersion (\"0.0.0.0\" ) ]"), "7 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly :AssemblyInformationalVersion(\"0.0.0.0\")]"), "8 Invalid match for an assembly version"); }
public void Regex_MatchesForAssembly() { VersionFileUpdater sut = new VersionFileUpdater(); //var rxstr = "\\s*\\[\\s*assembly\\s*:\\s*AssemblyVersion\\s*\\(\\s*\\\"\\s*[0-9A-z\\-.*]*\\s*\\\"\\s*\\)\\s*\\]"; //var rx = new Regex(rxstr, RegexOptions.IgnoreCase); var rx = sut.GetRegex("AssemblyVersion"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0.0.0\")]"), "1 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0.0\")]"), "2 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0.0\")]"), "3 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"0\")]"), "4 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion(\"\")]"), "5 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly: AssemblyVersion (\"0.0.0.0\" ) ]"), "7 Invalid match for an assembly version"); Assert.True(rx.IsMatch("[assembly :AssemblyVersion(\"0.0.0.0\")]"), "8 Invalid match for an assembly version"); // Assert.False(rx.IsMatch("//[assembly: AssemblyVersion(\"0.0.0.0\")]"), "6 Invalid match for an assembly version"); // Assert.False(rx.IsMatch(" // [assembly: AssemblyVersion(\"0.0.0.0\")]"), "9 Invalid match for an assembly version"); }