public SmokeTest ToSmokeTestOrNull() { // We just need to fill in the arguments... var candidate = new SmokeTest { Client = Client, Method = Method }; // Parameterless RPCs are very rare, but are good candidates for smoke tests. // Admittedly this has some false positives, e.g. in Vision, ProductSearchClient.PurgeProducts. if (Overloads.Any(o => o.RequiredParameters.Count == 0)) { // No arguments required return(candidate); } // If there's a method that accepts just a ProjectName, find its equivalent accepting a string. (There should be exactly one.) if (Overloads.Any(o => o.HasSingleParameterOfType("Google.Api.Gax.ResourceNames.ProjectName"))) { var stringParameter = Overloads.Single(o => o.HasSingleParameterOfType(typeof(string))).RequiredParameters[0]; candidate.Arguments[stringParameter.Name] = "projects/${PROJECT_ID}"; return(candidate); } // If there's a method that accepts just a LocationName, find its equivalent accepting a string. (There should be exactly one.) if (Overloads.Any(o => o.HasSingleParameterOfType("Google.Api.Gax.ResourceNames.LocationName"))) { var stringParameter = Overloads.Single(o => o.HasSingleParameterOfType(typeof(string))).RequiredParameters[0]; candidate.Arguments[stringParameter.Name] = "projects/${PROJECT_ID}/locations/us-east1"; return(candidate); } return(null); }
private bool VerifyDateTimeParseOverloads(Overloads overloads) { if (overloads.Name != "Parse") { return(false); } if (overloads.ReturnType != "DateTime") { return(false); } if (overloads.Count() != 3) { return(false); } var threeParams = overloads.Single(method => method.Parameters.Count == 3).Parameters.ToArray(); if (threeParams[0].Name != "s") { return(false); } if (threeParams[0].Type != "string") { return(false); } if (threeParams[1].Name != "provider") { return(false); } if (threeParams[1].Type != "IFormatProvider") { return(false); } if (threeParams[2].Name != "styles") { return(false); } if (threeParams[2].Type != "DateTimeStyles") { return(false); } return(true); }