Click here to Skip to main content
15,846,211 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
created a custom code activity for calculation of any given expression from console.Its a workflow console application.It works fine but the unit test created for this activity has run time issue.I followed creating a unit test for any activity from pro WF4 book.It takes too long to run these tests and when i stop and see the run results:0/2 tests passed,0 failed, 2 skipped.how can i solve this?

I have created testproject in the same solution and trying to run the test.
ParseCalculationArgsTest is the class file,contains the below code

C#
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Calculator;
using System.Activities;

namespace CalculatorTest
{
    [TestClass]
    public class ParseCalculatorArgsTest
    {
        [TestMethod]
        public void ValidExpressionTest()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("Expression", " 1 + 2 ");
            IDictionary<string, object> outputs = WorkflowInvoker.Invoke(new ParseCalculatorArgs(), parameters);
            Assert.IsNotNull(outputs, "Outputs should not be null");
            Assert.AreEqual(3, outputs.Count, "Output count sould be there");
            Assert.AreEqual((Double)1, outputs["FirstNumber"], "FirstNUmber should not be incorrect");
            Assert.AreEqual((Double)2, outputs["SecondNumber"], "Second number shouldn't be incorrect");
            Assert.AreEqual("+", outputs["Operation"], "Operation is inccorect");
 
        }

        [TestMethod]
        public void InvalidExpressionTest()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("Expression", " badexpression ");
            IDictionary<string, object> outputs = WorkflowInvoker.Invoke(new ParseCalculatorArgs(), parameters);
            Assert.IsNotNull(outputs, "Outputs should not be null");
            Assert.AreEqual(3, outputs.Count, "Output count sould be there");          
            Assert.AreEqual("error", outputs["Operation"], "Operation is inccorect");
        }
    }
}


Any sugestion how to run these test successfully ,so that it will show the result as passed.
Posted
Updated 17-Aug-13 18:24pm
v3
Comments
Ron Beyer 17-Aug-13 23:28pm    
Have you tried debugging your unit tests? Can you tell us what line its hung up at? Have you tried running the workflow to make sure its not hanging in there somewhere?
keerth516 19-Aug-13 5:37am    
Thanks for the reply when i start debugging with out running the test,it does not show any error,all break points in ParseCalculatorArgsTest's status message saying" the break point will not be currently hit,No Symbols have been loaded for this document".
keerth516 19-Aug-13 6:00am    
Once i stop test run,if i run it againg or tries to start debug ,it gives "Cannot start more than one local run" error.To run the test again, i have to close the application and then start it again.any solution for this?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900