internal void GivenTheProductsAreAssignedToClashCodesAndAdvertiserIdentifierWhenTheRestrictionValuesAreSetForEachCode_ThenTheProductsWithMoreRestrictionValuesAssignToThemGetTheMinimumRestrictionValue()
        {
            var runningTotal = new SmoothSponsorshipRunningTotals();

            runningTotal.AddCompetitorToClashCode("p1", "c1");
            runningTotal.AddCompetitorToClashCode("p2", "c1");
            runningTotal.AddCompetitorToClashCode("p1", "c2");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p2", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a2");

            runningTotal.SetRestrictionValueForClashCode("c1", 10);
            runningTotal.SetRestrictionValueForClashCode("c2", 20);
            runningTotal.SetRestrictionValueForClashCode("c1", 1);
            runningTotal.SetRestrictionValueForClashCode("c2", 2);
            runningTotal.SetRestrictionValueForClashCode("a1", 100);
            runningTotal.SetRestrictionValueForClashCode("a2", 200);
            runningTotal.SetRestrictionValueForClashCode("a1", 10);
            runningTotal.SetRestrictionValueForClashCode("a2", 20);

            var restrictionValuesForCompetitors = runningTotal.GetRestrictionValuesForCompetitors();

            Assert.Equal(new ProductExternalReference[] { "p1", "p2", "c1", "c2", "a1", "a2" }, restrictionValuesForCompetitors.Keys.ToArray());
            Assert.Equal(1, restrictionValuesForCompetitors["p1"]);
            Assert.Equal(1, restrictionValuesForCompetitors["p2"]);
            Assert.Equal(1, restrictionValuesForCompetitors["c1"]);
            Assert.Equal(2, restrictionValuesForCompetitors["c2"]);
            Assert.Equal(10, restrictionValuesForCompetitors["a1"]);
            Assert.Equal(20, restrictionValuesForCompetitors["a2"]);
        }
        internal void GivenTheProductsAreAssignedToClashCodesAndAdvertiserIdentifierWhenTheGetAllCompetitorsIsCalled_ThenAListOfAllUniqueProductsIsReturned()
        {
            var runningTotal = new SmoothSponsorshipRunningTotals();

            runningTotal.AddCompetitorToClashCode("p1", "c1");
            runningTotal.AddCompetitorToClashCode("p2", "c1");
            runningTotal.AddCompetitorToClashCode("p1", "c2");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p2", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a2");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p3", "a3");

            var competitors = runningTotal.GetAllCompetitors();

            Assert.Equal(new ProductExternalReference[] { "p1", "p2", "p3" }, competitors);
        }
        internal void GivenProductIdsAreAddedToSomeClashesAndAdvertisersCodes_TheAllProductIdsInClashOrAdvertiserCodeWillContainsAllTheValues()
        {
            var runningTotal = new SmoothSponsorshipRunningTotals();

            runningTotal.AddCompetitorToClashCode("p1", "c1");
            runningTotal.AddCompetitorToClashCode("p2", "c1");
            runningTotal.AddCompetitorToClashCode("p1", "c2");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p2", "a1");
            runningTotal.AddCompetitorToAdvertiserIdentifier("p1", "a2");

            Assert.Equal(new string[] { "c1", "c2", "a1", "a2" }, runningTotal.AllProductIdsInClashOrAdvertiserCode.Keys.ToArray());
            Assert.Equal(new ProductExternalReference[] { "p1", "p2" }, runningTotal.AllProductIdsInClashOrAdvertiserCode["c1"].ToArray());
            Assert.Equal(new ProductExternalReference[] { "p1", "p2" }, runningTotal.AllProductIdsInClashOrAdvertiserCode["a1"].ToArray());
            Assert.Equal(new ProductExternalReference[] { "p1" }, runningTotal.AllProductIdsInClashOrAdvertiserCode["c2"].ToArray());
            Assert.Equal(new ProductExternalReference[] { "p1" }, runningTotal.AllProductIdsInClashOrAdvertiserCode["a2"].ToArray());
        }
Beispiel #4
0
        private static SmoothSponsorshipRunningTotals GetSampleDataForEachCompetitorWithNoSponsoredWhenCalculationTypeIsPercentage()
        {
            var input = new SmoothSponsorshipRunningTotals();

            input.AddCompetitorToClashCode("C1", "P330");
            input.AddCompetitorToClashCode("C2", "P330");
            input.AddCompetitorToClashCode("C3", "P330");

            input.AddCompetitorToClashCode("C1", "P220");
            input.AddCompetitorToClashCode("C2", "P220");
            input.AddCompetitorToClashCode("C3", "P220");

            input.AddCompetitorToAdvertiserIdentifier("C1", "A110");
            input.AddCompetitorToAdvertiserIdentifier("C4", "A110");
            input.AddCompetitorToAdvertiserIdentifier("C5", "A110");

            input.AddCompetitorToAdvertiserIdentifier("C1", "A20");
            input.AddCompetitorToAdvertiserIdentifier("C6", "A20");
            input.AddCompetitorToAdvertiserIdentifier("C7", "A20");

            input.SetRestrictionValueForClashCode("P330", 10);
            input.SetRestrictionValueForClashCode("P220", 11);
            input.SetRestrictionValueForAdvertiserIdentifier("A110", 5);
            input.SetRestrictionValueForAdvertiserIdentifier("A20", 3);

            input.AddCompetitorToSpotByCount("C1", 1);
            input.AddCompetitorToSpotByCount("C2", 1);
            input.AddCompetitorToSpotByCount("C5", 2);

            return(input);
        }
Beispiel #5
0
        private static SmoothSponsorshipRunningTotals GetSampleDataForAllCompetitorsWhenCalculationTypeIsFlat()
        {
            var input = new SmoothSponsorshipRunningTotals();

            input.AddCompetitorToClashCode("C1", "P330");
            input.AddCompetitorToClashCode("C2", "P330");
            input.AddCompetitorToClashCode("C3", "P330");

            input.AddCompetitorToClashCode("C1", "P220");
            input.AddCompetitorToClashCode("C2", "P220");
            input.AddCompetitorToClashCode("C3", "P220");

            input.AddCompetitorToAdvertiserIdentifier("C1", "A110");
            input.AddCompetitorToAdvertiserIdentifier("C4", "A110");
            input.AddCompetitorToAdvertiserIdentifier("C5", "A110");

            input.AddCompetitorToAdvertiserIdentifier("C1", "A20");
            input.AddCompetitorToAdvertiserIdentifier("C6", "A20");
            input.AddCompetitorToAdvertiserIdentifier("C7", "A20");

            input.SetRestrictionValueForClashCode("P330", 5);
            input.SetRestrictionValueForClashCode("P220", 5);
            input.SetRestrictionValueForAdvertiserIdentifier("A110", 5);
            input.SetRestrictionValueForAdvertiserIdentifier("A20", 5);

            input.AddCompetitorToSpotByCount("C1", 1);
            input.AddCompetitorToSpotByCount("C5", 2);

            input.AddSponsoredProductToSpotByCount("SP1", 1);
            input.AddSponsoredProductToSpotByCount("SP2", 1);
            input.AddSponsoredProductToSpotByCount("SP3", 1);

            return(input);
        }