Beispiel #1
0
        public void InvokesTaskMethodWithOptionalStringParameterGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Optional"), Resolver);
            task.Invoke(new Arguments(new Dictionary<string, string>{{"fileName", "thefile.txt"}}));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"optional fileName: thefile.txt"));
        }
Beispiel #2
0
        public void InvokesTaskMethodWithStringParameter()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Deploy"), Resolver);
            task.Invoke(new TaskParameters(new Dictionary<string, string> { { "dir", @"c:\sites" } }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"deploying c:\sites"));
        }
Beispiel #3
0
        public void InvokesTaskMethodWithNullableIntParameterGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Nullable"), Resolver);
            task.Invoke(new TaskParameters(new Dictionary<string, string>{{"port", "80"}}));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"port: 80"));
        }
Beispiel #4
0
        public void InvokesTaskMethodWithOptionalStringParameterNotGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Optional"), Resolver);
            task.Invoke(new TaskParameters(new Dictionary<string, string>()));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"optional fileName: stuff.txt"));
        }
Beispiel #5
0
        public void InvokesTaskMethodWithNoParameters()
        {
            var task = new TaskMethod(typeof (FakeTaskClass).GetMethod("Compile"), Resolver);
            task.Invoke(new TaskParameters(new Dictionary<string, string>()));

            Assert.That(Output.ToString().Trim(), Is.EqualTo("compiling"));
        }
Beispiel #6
0
        public void InvokesTaskMethodWithBooleanParameter()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Test"), Resolver);
            task.Invoke(new TaskParameters(new Dictionary<string, string> { { "fast", @"true" } }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"testing fast"));
        }
Beispiel #7
0
        public void InvokesTaskMethodWithOptionalStringParameterNotGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Optional"), Resolver);

            task.Invoke(new TaskParameters(new Dictionary <string, string>()));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"optional fileName: stuff.txt"));
        }
Beispiel #8
0
        public void InvokesTaskMethodWithNoParameters()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Compile"), Resolver);

            task.Invoke(new TaskParameters(new Dictionary <string, string>()));

            Assert.That(Output.ToString().Trim(), Is.EqualTo("compiling"));
        }
Beispiel #9
0
        public void InvokesTaskMethodWithBooleanParameter()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Test"), Resolver);

            task.Invoke(new TaskParameters(new Dictionary <string, string> {
                { "fast", @"true" }
            }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"testing fast"));
        }
Beispiel #10
0
        public void InvokesTaskMethodWithStringParameter()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Deploy"), Resolver);

            task.Invoke(new TaskParameters(new Dictionary <string, string> {
                { "dir", @"c:\sites" }
            }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"deploying c:\sites"));
        }
Beispiel #11
0
        public void InvokesTaskMethodWithNullableIntParameterGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Nullable"), Resolver);

            task.Invoke(new TaskParameters(new Dictionary <string, string> {
                { "port", "80" }
            }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"port: 80"));
        }
Beispiel #12
0
        public void InvokesTaskMethodWithOptionalStringParameterGiven()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Optional"), Resolver);

            task.Invoke(new Arguments(new Dictionary <string, string> {
                { "fileName", "thefile.txt" }
            }));

            Assert.That(Output.ToString().Trim(), Is.EqualTo(@"optional fileName: thefile.txt"));
        }
Beispiel #13
0
        public void TaskExceptionIsThrownWhenTaskThrows()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Throws"), Resolver);

            Assert.That(() => task.Invoke(new TaskParameters(new Dictionary <string, string>())), Throws.InstanceOf <TaskException>());
        }
 public void DoTask()
 {
     taskMethod.Invoke(model);
 }
Beispiel #15
0
 public void TaskExceptionIsThrownWhenTaskThrows()
 {
     var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Throws"), Resolver);
     Assert.That(() => task.Invoke(new TaskParameters(new Dictionary<string, string>())), Throws.InstanceOf<TaskException>());
 }
Beispiel #16
0
 public void ThrowsExceptionWhenTaskRequiredParameterNotProvided()
 {
     var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Test"), Resolver);
     Assert.That(() => task.Invoke(new TaskParameters(new Dictionary<string, string>())), Throws.InstanceOf<TaskRequiredParameterException>());
 }
Beispiel #17
0
        public void ThrowsExceptionWhenTaskRequiredParameterNotProvided()
        {
            var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Test"), Resolver);

            Assert.That(() => task.Invoke(new TaskParameters(new Dictionary <string, string>())), Throws.InstanceOf <TaskRequiredParameterException>());
        }
Beispiel #18
0
 public void ThrowsExceptionWhenCustomTypeCannotBeParsed()
 {
     var task = new TaskMethod(typeof(FakeTaskClass).GetMethod("Bad"), Resolver);
     Assert.That(() => task.Invoke(new TaskParameters(new Dictionary<string, string> { { "x", @"something" } })), Throws.InstanceOf<TaskParameterException>());
 }