Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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"));
        }
Exemple #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);
 }
Exemple #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>());
 }
Exemple #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>());
 }
Exemple #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>());
        }
Exemple #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>());
 }