public void ValidArgs_AreCorrectlyParsed(string commandLine, string owner, string repo, bool invert, string[] matchers) { var console = new Mock <IConsole>(); console.Setup(c => c.ReadPassword(It.IsAny <string>())).Returns("PW"); console.Setup(c => c.ReadUsername()).Returns("User"); var(result, _) = CUT.Parse(commandLine.Split(' '), console.Object); Assert.AreEqual(owner, result.ProjectOwner); Assert.AreEqual(repo, result.ProjectName); Assert.AreEqual(invert, result.InvertedMatching); Assert.AreEqual(matchers, result.CleanReleases); }
public void UnknownArgument_ProvokesMessage(string commandLine, int[] unknownIndices) { var console = new Mock <IConsole>(); var parts = commandLine.Split(' '); console.Setup(c => c.Write(It.IsAny <string>())) .Verifiable(); try { CUT.Parse(parts, console.Object); } catch (Exception) { // this is not what we're testing here, so Exceptions during parsing are ignored } foreach (var index in unknownIndices) { console.Verify(c => c.Write(It.IsRegex($".*{parts[index]}.*")), Times.Once()); } }
public void InsufficientArgs_IsRejected(string commandLine) { var console = new Mock <IConsole>(); Assert.Throws <ArgumentException>(() => CUT.Parse(commandLine.Split(' '), console.Object)); }