Ejemplo n.º 1
0
        public void TheImpossibleCommandTypeCantWork()
        {
            var types   = new[] { typeof(CommandTypeWithoutDefaultConstructor) };
            var command = Command.FromArguments("Test");

            Expect.Throw <InvalidOperationException>(() => command.Run(types));
        }
Ejemplo n.º 2
0
        public void TheImpossibleCommandCantWork()
        {
            var types   = new[] { typeof(ExampleCommandType) };
            var command = Command.FromArguments("TheImpossibleCommand", "/impossible:yes");

            Expect.Throw <InvalidOperationException>(() => command.Run(types));
        }
Ejemplo n.º 3
0
        public void ThrowExpectsException()
        {
            Expect.Throw <Exception>(() =>
            {
                throw new Exception();
            });

            Expect.Throw <ApplicationException>("Ha!",
                                                () => { throw new ApplicationException("Ha!"); });
        }
Ejemplo n.º 4
0
        public void CommandCanFindNamedMethods()
        {
            var types   = new[] { typeof(ExampleCommandType) };
            var command = Command.FromArguments("ExampleCommandType.ExampleCommand");
            var methods = command.FindSuitableMethods(types).ToArray();

            Assert.IsNotNull(methods);
            Assert.AreEqual(2, methods.Length);
            Assert.IsTrue(methods.All(method => method.Name == "ExampleCommand"));

            Expect.Throw <InvalidOperationException>(() => command.FindSuitableMethods(new Type[] {}));
        }
Ejemplo n.º 5
0
 public void ThrowsRequiresExceptionWithMessage()
 {
     Expect.Throw <InvalidOperationException>("Needs a message.",
                                              () => { throw new InvalidOperationException(); });
 }
Ejemplo n.º 6
0
 public void ThrowsRequiresException()
 {
     Expect.Throw <InvalidOperationException>(() => { });
 }