public void GivenDemographicForAnyAgeAndSpecificState_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfMemberIsInThatState([ValueSource("AllStates")] State memberState, [ValueSource("AllStates")] State demographicState)
        {
            var member = new Member("Name", memberState, new DateTime(1970, 1, 1));
            var demographic = new Demographic(demographicState, null, null);

            var applies = demographic.Contains(member, DateTime.UtcNow);

            Assert.That(applies, Is.EqualTo(memberState == demographicState));
        }
        public virtual void CreateCampaign(DateTime now, Demographic demographic, DateTime start, DateTime end)
        {
            if (LatestCampaign != null && LatestCampaign.GetStatus(now) != CampaignStatus.Ended)
                throw new InvalidOperationException("You can't start a campaign until the existing one has ended.");

            var campaign = new Campaign(demographic, start, end);
            _campaigns.Add(campaign);
            LatestCampaign = campaign;
        }
        public void GivenDemographicWithStateAndAgeRange_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfTheMemberConformsToAllParameters([Range(1, 25)] int age, [ValueSource("AllStates")] State state)
        {
            var now = DateTime.UtcNow;
            var member = new Member("Name", state, now.AddYears(-age));
            var demographic = new Demographic(State.Wa, 18, 19);

            var applies = demographic.Contains(member, now);

            Assert.That(applies, Is.EqualTo(state == State.Wa && (age == 18 || age == 19)));
        }
        public void GivenDemographicForAnyStateWithMinimumAge_WhenCheckingIfTheDemographicAppliesToAMember_ThenReturnTrueOnlyIfMemberIsThatAgeOrOlder([Range(1, 25)] int memberAge, [Range(1, 25)] int minimumAge)
        {
            var now = DateTime.UtcNow;
            var member = new Member("Name", State.Wa, now.AddYears(-(memberAge+1)).AddSeconds(1));
            var demographic = new Demographic(null, minimumAge, null);

            var applies = demographic.Contains(member, now);

            Assert.That(applies, Is.EqualTo(memberAge >= minimumAge));
        }
Ejemplo n.º 5
0
        public virtual void CreateCampaign(DateTime now, Demographic demographic, DateTime start, DateTime end)
        {
            if (LatestCampaign != null && LatestCampaign.GetStatus(now) != CampaignStatus.Ended)
            {
                throw new InvalidOperationException("You can't start a campaign until the existing one has ended.");
            }

            var campaign = new Campaign(demographic, start, end);

            _campaigns.Add(campaign);
            LatestCampaign = campaign;
        }
Ejemplo n.º 6
0
 public Campaign(Demographic demographic, DateTime startDate, DateTime endDate)
 {
     Demographic = demographic;
     StartDate   = startDate;
     EndDate     = endDate;
 }
 public Campaign(Demographic demographic, DateTime startDate, DateTime endDate)
 {
     Demographic = demographic;
     StartDate = startDate;
     EndDate = endDate;
 }