public void GetVersionTestDateTime()
        {
            // Initialise Instance
            var target = new TfsVersion {
                Action = TfsVersionAction.GetVersion, PaddingCount = 5, PaddingDigit = '1', DateFormat = "MMdd", Delimiter = "."
            };

            // Declare additional parameters
            var parameters = new Dictionary <string, object>
            {
                { "Major", "1" },
                { "Minor", "5" },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            IBuildDetail    t       = new MockIBuildDetail {
                BuildNumber = "MyBuild_20101101.2"
            };

            t.BuildDefinition.Name = "MyBuild";
            invoker.Extensions.Add(t);

            var actual = invoker.Invoke(parameters);

            // Test the result
            Assert.AreEqual("1.5.11101.2", actual["Version"].ToString());
        }
        public void GetVersionTestElapsed()
        {
            // Initialise Instance
            var target = new TfsVersion {
                Action = TfsVersionAction.GetVersion, VersionTemplateFormat = "0.0.1000.0", StartDate = Convert.ToDateTime("1 Mar 2009"), VersionFormat = TfsVersionVersionFormat.Elapsed, UseUtcDate = true
            };

            // Declare additional parameters
            var parameters = new Dictionary <string, object>
            {
                { "Major", "3" },
                { "Minor", "1" },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            IBuildDetail    t       = new MockIBuildDetail {
                BuildNumber = "MyBuild_" + DateTime.Now.ToString("yyyyMMdd") + ".2"
            };

            t.BuildDefinition.Name = "MyBuild";
            invoker.Extensions.Add(t);

            var actual = invoker.Invoke(parameters);

            // Test the result
            DateTime d    = Convert.ToDateTime("1 Mar 2009");
            TimeSpan ts   = DateTime.Now - d;
            string   days = ts.Days.ToString();

            Assert.AreEqual("3.1.1" + days + ".2", actual["Version"].ToString());
        }
        public void GetVersionTestElapsed()
        {
            // Initialise Instance
            var target = new TfsVersion { Action = TfsVersionAction.GetVersion, VersionTemplateFormat = "0.0.1000.0", StartDate = Convert.ToDateTime("1 Mar 2009"), VersionFormat = TfsVersionVersionFormat.Elapsed, UseUtcDate = true };

            // Declare additional parameters
            var parameters = new Dictionary<string, object>
            {
                { "Major", "3" },
                { "Minor", "1" },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            IBuildDetail t = new MockIBuildDetail { BuildNumber = "MyBuild_" + DateTime.Now.ToString("yyyyMMdd") + ".2" };
            t.BuildDefinition.Name = "MyBuild";
            invoker.Extensions.Add(t);

            var actual = invoker.Invoke(parameters);

            // Test the result
            DateTime d = Convert.ToDateTime("1 Mar 2009");
            TimeSpan ts = DateTime.Now - d;
            string days = ts.Days.ToString();
            Assert.AreEqual("3.1.1" + days + ".2", actual["Version"].ToString());
        }
        public void GetVersionTestDateTime()
        {
            // Initialise Instance
            var target = new TfsVersion { Action = TfsVersionAction.GetVersion, PaddingCount = 5, PaddingDigit = '1', DateFormat = "MMdd", Delimiter = "." };

            // Declare additional parameters
            var parameters = new Dictionary<string, object>
                                 {
                                     { "Major", "1" },
                                     { "Minor", "5" },
                                 };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            IBuildDetail t = new MockIBuildDetail { BuildNumber = string.Format("MyBuild_{0}{1}{2}.2", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day) };
            t.BuildDefinition.Name = "MyBuild";
            invoker.Extensions.Add(t);
            
            var actual = invoker.Invoke(parameters);

            // Test the result
            Assert.AreEqual(string.Format("1.5.1{0}{1}.2", DateTime.Now.Month, DateTime.Now.Day), actual["Version"].ToString());
        }
        public void ExecuteTest2()
        {
            // Initialise Instance
            var target = new Hello { Message = "World" };

            // Declare additional parameters
            var parameters = new Dictionary<string, object>
            {
                { "Message2", " hope you are well" },
            };

            // Create the Workflow object
            WorkflowInvoker invoker = new WorkflowInvoker(target);

            // Create a Mock build detail object
            IBuildDetail t = new MockIBuildDetail { BuildNumber = "MyBuildNumber" };
            invoker.Extensions.Add(t);

            // Invoke the workflow
            var actual = invoker.Invoke(parameters);

            // Test the result wich is now accessed via the named Result key
            Assert.AreEqual("Hello World hope you are well from MyBuildNumber", actual["Result"]);
        }
        public void GetVersionTestCombineBuildAndRevisionDateTime()
        {
            // Initialise Instance
            var target = new TfsVersion { CombineBuildAndRevision = true, Action = TfsVersionAction.GetVersion, PaddingCount = 5, PaddingDigit = '1', DateFormat = "MMdd", Delimiter = "." };

            // Declare additional parameters
            var parameters = new Dictionary<string, object>
            {
                { "Major", "1" },
                { "Minor", "5" },
            };

            // Create a WorkflowInvoker and add the IBuildDetail Extension
            WorkflowInvoker invoker = new WorkflowInvoker(target);
            IBuildDetail t = new MockIBuildDetail { BuildNumber = "MyBuild_20101101.2" };
            t.BuildDefinition.Name = "MyBuild";
            invoker.Extensions.Add(t);

            var actual = invoker.Invoke(parameters);

            // Test the result
            Assert.AreEqual("1.5.11101.111012", actual["Version"].ToString());
        }