예제 #1
0
        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);
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        public void InsufficientArgs_IsRejected(string commandLine)
        {
            var console = new Mock <IConsole>();

            Assert.Throws <ArgumentException>(() => CUT.Parse(commandLine.Split(' '), console.Object));
        }