public void Init() {
   TestUtils utils = new TestUtils();
   placementService = (PlacementService) user.GetService(DfpService.v201403.PlacementService);
   adUnit1 = utils.CreateAdUnit(user);
   adUnit2 = utils.CreateAdUnit(user);
   placement = utils.CreatePlacement(user, new string[] {adUnit1.id, adUnit2.id});
 }
    public void TestCreatePlacements() {
      TestUtils utils = new TestUtils();
      Placement placement1 = new Placement();
      placement1.name = string.Format("Medium Square AdUnit Placement #{0}", utils.GetTimeStamp());
      placement1.description = "Contains ad units that can hold creatives of size 300x250";
      placement1.targetedAdUnitIds = new string[] {adUnit1.id, adUnit2.id};

      Placement placement2 = new Placement();
      placement2.name = string.Format("Medium Square AdUnit Placement #{0}", utils.GetTimeStamp());
      placement2.description = "Contains ad units that can hold creatives of size 300x250";
      placement2.targetedAdUnitIds = new string[] {adUnit1.id, adUnit2.id};

      Placement[] newPlacements = null;

      Assert.DoesNotThrow(delegate() {
        newPlacements = placementService.createPlacements(new Placement[] {placement1, placement2});
      });

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

      Assert.NotNull(newPlacements[0]);
      Assert.AreEqual(newPlacements[0].name, placement1.name);
      Assert.AreEqual(newPlacements[0].description, placement1.description);
      Assert.Contains(adUnit1.id, newPlacements[0].targetedAdUnitIds);
      Assert.Contains(adUnit2.id, newPlacements[0].targetedAdUnitIds);

      Assert.NotNull(newPlacements[1]);
      Assert.AreEqual(newPlacements[1].name, placement2.name);
      Assert.AreEqual(newPlacements[1].description, placement2.description);
      Assert.Contains(adUnit1.id, newPlacements[1].targetedAdUnitIds);
      Assert.Contains(adUnit2.id, newPlacements[1].targetedAdUnitIds);
    }
 public void Init() {
   TestUtils utils = new TestUtils();
   userService = (UserService) user.GetService(DfpService.v201403.UserService);
   salespersonId = utils.GetSalesperson(user).id;
   traffickerId = utils.GetTrafficker(user).id;
   currentUserId = utils.GetCurrentUser(user).id;
 }
    public void Init() {
      TestUtils utils = new TestUtils();
      orderService = (OrderService) user.GetService(DfpService.v201403.OrderService);

      advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id;
      salespersonId = utils.GetSalesperson(user).id;
      traffickerId = utils.GetTrafficker(user).id;

      orderId = utils.CreateOrder(user, advertiserId, salespersonId, traffickerId).id;
    }
    public void Init() {
      TestUtils utils = new TestUtils();
      forecastService = (ForecastService)user.GetService(DfpService.v201403.ForecastService);
      advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id;
      salespersonId = utils.GetSalesperson(user).id;
      traffickerId = utils.GetTrafficker(user).id;

      orderId = utils.CreateOrder(user, advertiserId, salespersonId, traffickerId).id;
      adUnitId = utils.CreateAdUnit(user).id;
      placementId = utils.CreatePlacement(user, new string[] {adUnitId}).id;
      lineItemId = utils.CreateLineItem(user, orderId, adUnitId).id;
    }
 public void Init() {
   TestUtils utils = new TestUtils();
   companyService = (CompanyService) user.GetService(DfpService.v201403.CompanyService);
   testCompany1 = utils.CreateCompany(user, CompanyType.ADVERTISER);
   testCompany2 = utils.CreateCompany(user, CompanyType.ADVERTISER);
 }
 public void Init() {
   TestUtils utils = new TestUtils();
   inventoryService = (InventoryService) user.GetService(DfpService.v201403.InventoryService);
   adUnit1 = utils.CreateAdUnit(user);
   adUnit2 = utils.CreateAdUnit(user);
 }
    public void TestGetForecast() {
      TestUtils utils = new TestUtils();

      LineItem lineItem = new LineItem();
      lineItem.name = string.Format("Line item #{0}", utils.GetTimeStamp());

      lineItem.orderId = orderId;

      lineItem.targeting = new Targeting();
      lineItem.targeting.inventoryTargeting = new InventoryTargeting();
      lineItem.targeting.inventoryTargeting.targetedPlacementIds = new long[] {placementId};

      Size size1 = new Size();
      size1.width = 300;
      size1.height = 250;

      Size size2 = new Size();
      size2.width = 120;
      size2.height = 600;

      // Create the creative placeholders.
      CreativePlaceholder creativePlaceholder1 = new CreativePlaceholder();
      creativePlaceholder1.size = size1;

      CreativePlaceholder creativePlaceholder2 = new CreativePlaceholder();
      creativePlaceholder1.size = size2;

      lineItem.creativePlaceholders =
          new CreativePlaceholder[] {creativePlaceholder1, creativePlaceholder2};

      lineItem.lineItemType = LineItemType.STANDARD;

      // Set start date time and end date time.
      lineItem.startDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddDays(1));
      lineItem.endDateTime = DateTimeUtilities.FromDateTime(System.DateTime.Today.AddMonths(1));

      lineItem.costType = CostType.CPM;
      lineItem.costPerUnit = new Money();
      lineItem.costPerUnit.currencyCode = "USD";
      lineItem.costPerUnit.microAmount = 2000000;

      lineItem.creativeRotationType = CreativeRotationType.EVEN;
      lineItem.discountType = LineItemDiscountType.PERCENTAGE;

      lineItem.unitsBought = 500000;
      lineItem.unitType = UnitType.IMPRESSIONS;

      Forecast forecast = null;
      Assert.DoesNotThrow(delegate() {
        forecast = forecastService.getForecast(lineItem);
      });
      Assert.NotNull(forecast);
      Assert.AreEqual(forecast.orderId, orderId);
      Assert.AreEqual(forecast.unitType, lineItem.unitType);
    }
    public void Init() {
      TestUtils utils = new TestUtils();
      licaService = (LineItemCreativeAssociationService) user.GetService(
          DfpService.v201403.LineItemCreativeAssociationService);
      advertiserId = utils.CreateCompany(user, CompanyType.ADVERTISER).id;
      salespersonId = utils.GetSalesperson(user).id;
      traffickerId = utils.GetTrafficker(user).id;

      orderId = utils.CreateOrder(user, advertiserId, salespersonId, traffickerId).id;
      adUnitId = utils.CreateAdUnit(user).id;

      lineItemId1 = utils.CreateLineItem(user, orderId, adUnitId).id;
      lineItemId2 = utils.CreateLineItem(user, orderId, adUnitId).id;
      lineItemId3 = utils.CreateLineItem(user, orderId, adUnitId).id;
      lineItemId4 = utils.CreateLineItem(user, orderId, adUnitId).id;

      creativeId1 = utils.CreateCreative(user, advertiserId).id;
      creativeId2 = utils.CreateCreative(user, advertiserId).id;
      creativeId3 = utils.CreateCreative(user, advertiserId).id;
      creativeId4 = utils.CreateCreative(user, advertiserId).id;

      lica1 = utils.CreateLica(user, lineItemId3, creativeId3);
      lica2 = utils.CreateLica(user, lineItemId4, creativeId4);
    }
 public void Init() {
   TestUtils utils = new TestUtils();
   reportService = (ReportService) user.GetService(DfpService.v201403.ReportService);
   reportId = utils.CreateReport(user).id;
 }