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);
    }
Esempio n. 2
0
        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;

            Goal goal = new Goal();

            goal.units           = 500000;
            goal.unitType        = UnitType.IMPRESSIONS;
            lineItem.primaryGoal = goal;

            Forecast forecast = null;

            Assert.DoesNotThrow(delegate() {
                forecast = forecastService.getForecast(lineItem);
            });
            Assert.NotNull(forecast);
            Assert.AreEqual(forecast.orderId, orderId);
            Assert.AreEqual(forecast.unitType, lineItem.primaryGoal.unitType);
        }
        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 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;

      Goal goal = new Goal();
      goal.units = 500000;
      goal.unitType = UnitType.IMPRESSIONS;
      lineItem.primaryGoal = goal;

      Forecast forecast = null;
      Assert.DoesNotThrow(delegate() {
        forecast = forecastService.getForecast(lineItem);
      });
      Assert.NotNull(forecast);
      Assert.AreEqual(forecast.orderId, orderId);
      Assert.AreEqual(forecast.unitType, lineItem.primaryGoal.unitType);
    }