public void GivenAModel_WhenCallingHelpWithCommandTopic_ThenHelpShouldContainTheRightUsageInformation()
        {
            // Arrange
            var controller = new Controller(new Mock(), c => c.AddHelp());

            // Act
            var actual = controller.ModelMap.Invoke("Help", "Command") as HelpDetails;

            // Assert
            var usage = actual?.Usage;

            Assert.NotNull(usage);
            Assert.Equal("Command", usage.Name);
            Assert.Equal("String", usage.ReturnType);
            Assert.Equal("Command", usage.DisplayName);
            Assert.Equal(2, usage.Arguments.Length);

            var first         = usage.Arguments.First();
            var firstExpected = new ArgumentDetails {
                Name = "argument", Type = "String"
            };

            Assert.Equal(firstExpected, first, new DetailsComparer());

            var second         = usage.Arguments[1];
            var secondExpected = new ArgumentDetails
            {
                Name         = "optional",
                Type         = "String",
                DisplayName  = null,
                Description  = "Some description",
                Optional     = true,
                DefaultValue = "default"
            };

            Assert.Equal(secondExpected, second, new DetailsComparer());
        }
Exemplo n.º 2
0
 private string CreateViolationMessageForUncertainCase(ArgumentDetails a)
 {
     return string.Format("the expected value used by {0} should be produced locally", a.Method.Name);
 }
Exemplo n.º 3
0
 private string CreateViolationMessage(ArgumentDetails a)
 {
     var sp = a.ConsumedValue.Consumer.FindSequencePoint();
     var lineInfo = sp == null ? "" : string.Format(" on line {0}", sp.StartLine);
     return string.Format(
             "external production of (possibly) expected value (argument {0} of {1}{2})",
             a.Index + 1, a.Method.Name, lineInfo);
 }