public override IEnumerable <ITestCommand> EnumerateTestCommands(IMethodInfo testMethod) { /// TODO - Advanced feature: /// 1. Frame filter, some cases can be filtered under some frame var combinations = from test in Proxy.EnumerateTestCommands(testMethod) from frame in _frames select new { TestCommand = test, RunFrame = frame }; foreach (var each in combinations) { var isSkipped = (each.TestCommand is DelegatingTestCommand) ? (each.TestCommand as DelegatingTestCommand).InnerCommand is SkipCommand : (each.TestCommand is SkipCommand); if (isSkipped) { yield return(each.TestCommand); } else { var testCommand = new NuwaTestCommand(each.TestCommand) { Frame = each.RunFrame, TestMethod = testMethod }; yield return(testCommand); } } }
/// <summary> /// Create an http client according to configuration and host strategy /// </summary> /// <param name="testClass">the test class under test</param> protected void SetHttpclient(object testClass, NuwaTestCommand testCommand) { Type testClassType = testClass.GetType(); // set the HttpClient if necessary var clientPrpt = testClassType.GetProperties() .Where(prop => { return(prop.GetCustomAttributes(typeof(NuwaHttpClientAttribute), false).Length == 1); }) .FirstOrDefault(); if (clientPrpt == null || NuwaHttpClientAttribute.Verify(clientPrpt) == false) { return; } // create a client strategy from the host strategy var strategy = testCommand.Frame.GetState(KeyClientStrategy) as IClientStrategy; if (strategy == null) { return; } // check the network crediential if (testCommand.TestMethod != null) { var credAttr = testCommand.TestMethod.GetFirstCustomAttribute <NuwaNetworkCredentialAttribute>(); if (credAttr != null) { strategy.Credentials = credAttr.Credential; } } // create client assign to property if (strategy != null) { strategy.MessageLog = this.MessageLog; clientPrpt.SetValue(testClass, strategy.CreateClient(), null); } else { // TODO: send warning } }
/// <summary> /// Create an http client according to configuration and host strategy /// </summary> /// <param name="testClass">the test class under test</param> protected void SetHttpclient(object testClass, NuwaTestCommand testCommand) { Type testClassType = testClass.GetType(); // set the HttpClient if necessary var clientPrpt = testClassType.GetProperties() .Where(prop => { return prop.GetCustomAttributes(typeof(NuwaHttpClientAttribute), false).Length == 1; }) .FirstOrDefault(); if (clientPrpt == null || NuwaHttpClientAttribute.Verify(clientPrpt) == false) { return; } // create a client strategy from the host strategy var strategy = testCommand.Frame.GetState(KeyClientStrategy) as IClientStrategy; if (strategy == null) { return; } // check the network crediential if (testCommand.TestMethod != null) { var credAttr = testCommand.TestMethod.GetFirstCustomAttribute<NuwaNetworkCredentialAttribute>(); if (credAttr != null) { strategy.Credentials = credAttr.Credential; } } // create client assign to property if (strategy != null) { strategy.MessageLog = this.MessageLog; clientPrpt.SetValue(testClass, strategy.CreateClient(), null); } else { // TODO: send warning } }
public override void Recover(object testClass, NuwaTestCommand testCommand) { SetHttpclient(testClass, testCommand); }
public override void Recover(object testClass, NuwaTestCommand testCommand) { SetBaseAddress(testClass, testCommand.Frame); }
public override void Recover(object testClass, NuwaTestCommand testCommand) { base.Recover(testClass, testCommand); }
public virtual void Recover(object testClass, NuwaTestCommand testCommand) { }