public void Execute_WhenRuleIsGiven_ShouldStoreIt()
        {
            var rule = new IntervalRule
                           {
                               Conditons = new List<string> { "gmail.com" },
                               Interval = 20,
                               Group = "gmail"
                           };

            ServiceActions.ExecuteCommand<AddIntervalRulesCommand>(x => x.Rules = new[] { rule });

            Store.WaitForEntitiesToExist<IntervalRule>(1);

            var result = Store.Query<IntervalRule>().First();

            result.Conditons.Should().Contain(new[] {"gmail.com"});
            rule.Interval.Should().Be(20);
            rule.Group.Should().Be("gmail");
        }
        public void Execute_WhenGivenIntervalRules_ShouldSetTheCorrectItnervalsAndGroup()
        {
            ServiceActions.EditSettings<CreativeFragmentSettings>(x => x.RecipientsPerFragment = 200);

            var rule = new IntervalRule
            {
                Conditons = new List<string> { "gmail.com", "hotmail.com" },
                Interval = 10,
                Group = "gmail"
            };

            ServiceActions.ExecuteCommand<AddIntervalRulesCommand>(x => x.Rules = new[] { rule });

            var contacts = AddRandomContacts(100);

            var topDomainContacts = new List<Contact>
                               {
                                   CreateContactWithEmail("*****@*****.**"),
                                   CreateContactWithEmail("*****@*****.**"),
                                   CreateContactWithEmail("*****@*****.**"),
                                   CreateContactWithEmail("*****@*****.**"),
                                   CreateContactWithEmail("*****@*****.**"),
                               };

            var listId = CraeteListFromContacts("my list", contacts.Union(topDomainContacts));

            var templateId = CreateTemplate("Body");

            var creativeId = UiActions.ExecuteCommand<AddCreativeCommand, string>(x =>
            {
                x.HtmlBody = "Body";
                x.Subject = "Subject";
                x.UnsubscribeTemplateId = templateId;
                x.Lists = new List<string> { listId };
            });

            var task = new CreateCreativeFragmentsTask
            {
                CreativeId = creativeId,
            };

            ServiceActions.ExecuteTask(task);

            var result = Store.Query<CreativeFragment>().First();

            result.Recipients.Should().Contain(x => topDomainContacts.Any(contact => contact.Email == x.Email) && x.Interval == 10 && x.Group == "gmail");
        }