如何为使用CodeActivity的类库编写单元测试?

时间:2018-09-19 13:42:55

标签: c# unit-testing class-library

有没有示例如何为使用CodeActivity的类库编写单元测试?它接受InArgument,输出OutArgument并具有Execute方法。这是我的课程库:

  public class Validation : CodeActivity
    {        
        [Category("Input")]
        [RequiredArgument]
        public InArgument<string> PickupZip { get; set; }           

        [Category("Output")]
        [RequiredArgument]
        public OutArgument<string> Output { get; set; }

        protected override async void Execute(CodeActivityContext context)
        {            
            try
            {                
                List<string> test = new List<string>();
                var origin = await 
                GoogleAPIWrapper.GetAddressByZip(PickupZip.Get(context));
                if (origin.StatusId >= 0)
                {                    
                    test.Add(origin.StreetNumber);
                    test.Add(origin.Locality);                   
                }                
                string temp = string.Join(",", test.ToArray());
                Output.Set(context, temp);
            }
            catch (Exception e)
            {
                Output.Set(context, e.toString());
            }
        }        

    }

谢谢!

0 个答案:

没有答案