Example #1
0
            public void CreatesGoodMenuItemFromDocumentedMethod()
            {
                var menuTarget = new TestMenuTarget();
                var target     = MenuItem.Print(() => menuTarget.DoItTheRightWayWithDocumentation());

                Assert.AreEqual("This is a good documented method.", target.DisplayString);
            }
Example #2
0
            public void AcceptsVoidMethods()
            {
                var menuTarget = new TestMenuTarget();
                var target     = MenuItem.Print(() => menuTarget.ThisIsAVoidMethod());

                Assert.AreEqual("This is a good documented void method.", target.DisplayString);
            }
Example #3
0
 public async Task NotMapsParametersByAnonymousTypePropertyName()
 {
     var   value      = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
     var   menuTarget = new TestMenuTarget();
     var   target     = MenuItem.MenuItemsFor <TestMenuTarget>(new { myParameterWrong = value, target = menuTarget });
     await target[2].ActionWithParameters(Array.Empty <object>()).ConfigureAwait(false);
 }
Example #4
0
            public void CreatesGoodMenuItemFromUndocumentedMethod()
            {
                var menuTarget = new TestMenuTarget();
                var target     = MenuItem.Print(() => menuTarget.DoItTheRightWay());

                Assert.AreEqual("Do It The Right Way", target.DisplayString);
            }
Example #5
0
            public async Task MapsParametersByType()
            {
                var   value      = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
                var   menuTarget = new TestMenuTarget();
                var   target     = MenuItem.MenuItemsFor <TestMenuTarget>(value, menuTarget);
                await target[2].ActionWithParameters(Array.Empty <object>()).ConfigureAwait(false);

                Assert.AreEqual(value, menuTarget.Parameter);
            }
Example #6
0
            public async Task InvokesAction2()
            {
                var menuTarget = new TestMenuTarget();
                var target     = new[] { MenuItem.Print(() => menuTarget.DoItTheRightWay()) };

                var simulator = new ConsoleSimulator("0", " ", " ");

                MenuItem.Console = simulator;

                await target.Show(simulator);

                Assert.AreEqual("{clear}", simulator.Output[0]);
                Assert.AreEqual("0) Do It The Right Way", simulator.Output[1]);
            }
Example #7
0
            public async Task InvokesAction()
            {
                var value      = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
                var menuTarget = new TestMenuTarget();
                var simulator  = new ConsoleSimulator("0", " ", " ");

                MenuItem.Console = simulator;

                var target = MenuItem.MenuItemsFor <TestMenuTarget>(new { myParameterWrong = value, target = menuTarget });
                await target.Show(simulator);

                Assert.AreEqual("{clear}", simulator.Output[0]);
                Assert.AreEqual("0) Do It The Right Way", simulator.Output[1]);
                Assert.AreEqual("1) This is a good documented method.", simulator.Output[2]);
                Assert.AreEqual("2) This is a good documented void method with parameter.", simulator.Output[3]);
                Assert.AreEqual("3) This is a good documented void method.", simulator.Output[4]);
                Assert.AreEqual("what should be executed?", simulator.Output[5]);
                Assert.AreEqual("executing menu item #0 Do It The Right Way", simulator.Output[6]);
                Assert.AreEqual("ok", simulator.Output[7]);
                Assert.AreEqual("done", simulator.Output[8]);
                Assert.AreEqual("press any key to continue", simulator.Output[9]);
            }
Example #8
0
 public void ThisIsAVoidMethod(string myParameter, TestMenuTarget target) => target.MustNotBeNull(nameof(target)).Parameter = myParameter;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
        public static Task <string> ReadSingleContact(TestMenuTarget client, Guid sampleCrmId) => Task.FromResult("ok");