public void TestEnumValues() { Dictionary <string, int> lookup = new Dictionary <string, int>(); // Enumerate through each of the enums and their fields. StubIntegrityTestHelper.EnumerateEnumFields <AdManagerService>(ROOT_NAMESPACE, // For each matching enum and field, process it. delegate(string hashedFieldName, int enumValue) { // If this key exists in the lookup table, then the value of that // entry should match the value of the enum field we are examining. int existingEnumValue = 0; if (lookup.TryGetValue(hashedFieldName, out existingEnumValue)) { Assert.AreEqual(existingEnumValue, enumValue, string.Format( "Enum value of {0} doesn't match. Old value: {1}, new value: {2}", hashedFieldName, existingEnumValue, enumValue)); } else { // Otherwise, this is a new enum type / field. Add it to the lookup map. lookup[hashedFieldName] = enumValue; } }); }
public void TestGetService() { // Get the method with two parameters. MethodInfo method = typeof(GoogleAdsServiceClientFactory).GetMethods( BindingFlags.NonPublic | BindingFlags.Instance) .ToList().Where(delegate(MethodInfo mi) { return(mi.Name == "GetService" && mi.GetParameters().Length == 2); }).First(); StubIntegrityTestHelper.EnumerateServices <Services>( delegate(System.Type serviceSignatureType) { Assert.DoesNotThrow(delegate() { List <System.Type> arguments = new List <System.Type>( serviceSignatureType.GenericTypeArguments); arguments.Add(typeof(GoogleAdsConfig)); MethodInfo genericMethod = method.MakeGenericMethod( serviceSignatureType.GenericTypeArguments); object result = genericMethod.Invoke(serviceClientFactory, new object[] { null, config }); }); }); }
public void TestCreateServices() { StubIntegrityTestHelper.EnumerateServices <AdManagerService>( delegate(ServiceSignature serviceSignature) { Assert.DoesNotThrow(delegate() { user.GetService(serviceSignature); }); }); }
public void TestCreateServices() { StubIntegrityTestHelper.EnumerateServices <DfpService>( delegate(ServiceSignature serviceSignature) { Assert.DoesNotThrow(delegate() { AdsClient service = user.GetService(serviceSignature); }); }); }
public void TestCreateServices() { StubIntegrityTestHelper.EnumerateServices <AdManagerService>( delegate(ServiceSignature serviceSignature) { Assert.DoesNotThrow(delegate() { user.GetService(serviceSignature); }, "Error when creating {0}.{1}", serviceSignature.Version, serviceSignature.ServiceName); }); }
public void TestGetService() { MethodInfo method = typeof(GoogleAdsClient).GetMethod("GetService"); StubIntegrityTestHelper.EnumerateServices <Services>( delegate(System.Type serviceSignatureType) { Assert.DoesNotThrow(delegate() { MethodInfo genericMethod = method.MakeGenericMethod( serviceSignatureType.GenericTypeArguments); object result = genericMethod.Invoke(googleAdsClient, new object[] { null }); }); }); }
public void TestGetService() { MethodInfo method = typeof(GoogleAdsServiceClientFactory).GetMethod("GetService", BindingFlags.NonPublic | BindingFlags.Instance); StubIntegrityTestHelper.EnumerateServices <Services>( delegate(System.Type serviceSignatureType) { Assert.DoesNotThrow(delegate() { List <System.Type> arguments = new List <System.Type>( serviceSignatureType.GenericTypeArguments); arguments.Add(typeof(GoogleAdsConfig)); MethodInfo genericMethod = method.MakeGenericMethod( serviceSignatureType.GenericTypeArguments); object result = genericMethod.Invoke(serviceClientFactory, new object[] { null, config }); }); }); }
public void TestGetService() { // Get the method with one parameter. MethodInfo method = typeof(GoogleAdsClient).GetMethods() .ToList().Where(delegate(MethodInfo mi) { return(mi.Name == "GetService" && mi.GetParameters().Length == 1); }).First(); StubIntegrityTestHelper.EnumerateServices <Services>( delegate(System.Type serviceSignatureType) { Assert.DoesNotThrow(delegate() { MethodInfo genericMethod = method.MakeGenericMethod( serviceSignatureType.GenericTypeArguments); object result = genericMethod.Invoke(googleAdsClient, new object[] { null }); }); }); }