public void AddMailrelaySubscriberFromLeadTestCanUpdateASubscriber() { DatabaseWebCampaign webCampaign = GetWebcampaign(); string email = "test"; DatabaseAddMailrelaySubscriberFromLead databaseAddMailrelaySubscriberFromLead = AddMailrelaySubscriberFromLead.CreateIfValid(Connection, _lead.Id, "test", "test", email, webCampaign); AddMailrelaySubscriberFromLead addMailrelaySubscriberFromLead = new AddMailrelaySubscriberFromLead(Connection, databaseAddMailrelaySubscriberFromLead); int randomId = new Random().Next(0, int.MaxValue); _mailrelayConnectionTester.replies.Enqueue(new MailrelayArrayReply <getSubscribersReply>() { status = 1, data = new List <getSubscribersReply>() { new getSubscribersReply() { email = email, id = randomId.ToString(), fields = new Dictionary <string, string>(), groups = new List <string>(), }, } }); _mailrelayConnectionTester.replies.Enqueue(new MailrelayIntReply() { status = 1, data = 1 }); ExecuteWithFakeMailrelayConnection(addMailrelaySubscriberFromLead); Console.Out.WriteLine(_mailrelayConnectionTester); updateSubscriber updateSubscriberFunction = (updateSubscriber)_mailrelayConnectionTester.sendFunctions.Single(function => function is updateSubscriber); Assert.AreEqual(email, updateSubscriberFunction.email); Assert.AreEqual(randomId, updateSubscriberFunction.id); }
public void AddMailrelaySubscriberFromLeadTestAddsASubscriber() { DatabaseWebCampaign webCampaign = GetWebcampaign(); DatabaseAddMailrelaySubscriberFromLead databaseAddMailrelaySubscriberFromLead = AddMailrelaySubscriberFromLead.CreateIfValid(Connection, Guid.Empty, "test", "test", "test", webCampaign); AddMailrelaySubscriberFromLead addMailrelaySubscriberFromLead = new AddMailrelaySubscriberFromLead(Connection, databaseAddMailrelaySubscriberFromLead); _mailrelayConnectionTester.replies.Enqueue(new MailrelayArrayReply <getSubscribersReply>() { status = 1, data = new List <getSubscribersReply>() }); _mailrelayConnectionTester.replies.Enqueue(new MailrelayIntReply() { status = 1, data = 1 }); ExecuteWithFakeMailrelayConnection(addMailrelaySubscriberFromLead); Console.Out.WriteLine(_mailrelayConnectionTester); Assert.IsTrue(_mailrelayConnectionTester.sendFunctions.Any(function => function is addSubscriber)); }