/// <summary>
    /// Run the code example.
    /// </summary>
    /// <param name="user">The DFP user object running the code example.</param>
    public override void Run(DfpUser user) {
      // Get the CompanyService.
      CompanyService companyService =
          (CompanyService) user.GetService(DfpService.v201308.CompanyService);

      // Create an array to store local company objects.
      Company[] companies = new Company[5];

      for (int i = 0; i < 5; i++) {
        Company company = new Company();
        company.name = string.Format("Advertiser #{0}", i);
        company.type = CompanyType.ADVERTISER;
        companies[i] = company;
      }

      try {
        // Create the companies on the server.
        companies = companyService.createCompanies(companies);

        if (companies != null && companies.Length > 0) {
          foreach (Company company in companies) {
            Console.WriteLine("A company with ID = '{0}', name = '{1}' and type = '{2}' was" +
                " created.", company.id, company.name, company.type);
          }
        } else {
          Console.WriteLine("No companies created.");
        }
      } catch (Exception ex) {
        Console.WriteLine("Failed to create company. Exception says \"{0}\"", ex.Message);
      }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Create a test company for running further tests.
    /// </summary>
    /// <returns>A test company for running further tests.</returns>
    public Company CreateCompany(DfpUser user, CompanyType companyType) {
      CompanyService companyService = (CompanyService) user.GetService(
          DfpService.v201308.CompanyService);
      Company company = new Company();
      company.name = string.Format("Company #{0}", GetTimeStamp());
      company.type = companyType;

      return companyService.createCompany(company);
    }
    public void TestCreateCompany() {
      Company company = new Company();
      company.name = string.Format("Company #{0}", new TestUtils().GetTimeStamp());
      company.type = CompanyType.ADVERTISER;

      Company newCompany = null;
      Assert.DoesNotThrow(delegate() {
        newCompany = companyService.createCompany(company);
      });

      Assert.NotNull(newCompany);
      Assert.AreEqual(company.name, newCompany.name);
      Assert.AreEqual(company.type, newCompany.type);
    }
    public void TestCreateCompanies() {
      Company company1 = new Company();
      company1.name = string.Format("Company #{0}", new TestUtils().GetTimeStamp());
      company1.type = CompanyType.ADVERTISER;

      Company company2 = new Company();
      company2.name = string.Format("Company #{0}", new TestUtils().GetTimeStamp());
      company2.type = CompanyType.ADVERTISER;

      Company[] newCompanies = null;
      Assert.DoesNotThrow(delegate() {
        newCompanies = companyService.createCompanies(new Company[] {company1, company2});
      });

      Assert.NotNull(newCompanies);
      Assert.AreEqual(newCompanies.Length, 2);

      Assert.AreEqual(company1.name, newCompanies[0].name);
      Assert.AreEqual(company1.type, newCompanies[0].type);
      Assert.AreEqual(company2.name, newCompanies[1].name);
      Assert.AreEqual(company2.type, newCompanies[1].type);
    }
 public void Init() {
   TestUtils utils = new TestUtils();
   companyService = (CompanyService) user.GetService(DfpService.v201308.CompanyService);
   testCompany1 = utils.CreateCompany(user, CompanyType.ADVERTISER);
   testCompany2 = utils.CreateCompany(user, CompanyType.ADVERTISER);
 }
Ejemplo n.º 6
0
 public virtual Company updateCompany(Company company)
 {
     object[] results = this.Invoke("updateCompany", new object[] { company });
       return ((Company) (results[0]));
 }