Inheritance: IPostmarkSpamcheck
        public void GetScore_should_use_PostmarkSpamcheckWebClient_to_get_a_spamcheck_result()
        {
            // Arrange
            var jsonResponse = "{\"success\":true,\"score\":\"7.9/5.0\n\"}";
            var mockPostmarkSpamcheckWebClient = MockRepository.GenerateMock<IPostmarkSpamcheckWebClient>();
            var spamCheck = new PostmarkSpamcheck(mockPostmarkSpamcheckWebClient);
            mockPostmarkSpamcheckWebClient
                .Stub(a => a.GetSpamcheckResult(Arg<SpamcheckScoreRequest>.Is.Anything))
                    .Return(jsonResponse);

            // Act
            spamCheck.GetScore("Email");

            //Assert
            mockPostmarkSpamcheckWebClient
                .AssertWasCalled(a => a.GetSpamcheckResult(Arg<SpamcheckScoreRequest>.Is.Anything));
        }
        public void GetScore_should_deserialize_json_correctly()
        {
            // Arrange
            var jsonResponse = "{\"success\":true,\"score\":\"7.9/5.0\n\"}";
            var mockPostmarkSpamcheckWebClient = MockRepository.GenerateStub<IPostmarkSpamcheckWebClient>();
            var spamCheck = new PostmarkSpamcheck(mockPostmarkSpamcheckWebClient);
            mockPostmarkSpamcheckWebClient
                .Stub(a => a.GetSpamcheckResult(Arg<SpamcheckScoreRequest>.Is.Anything))
                    .Return(jsonResponse);

            // Act
            var result = spamCheck.GetScore("Email");

            //Assert
            Assert.AreEqual(true, result.Success);
            Assert.AreEqual("7.9/5.0\n", result.Score);
        }
Exemplo n.º 3
0
 public static void Main(string[] args)
 {
     var email = Console.ReadLine();
     var spamChecker = new PostmarkSpamcheck();
     var score = spamChecker.GetScore(email);
     if (score.Success)
     {
         Console.WriteLine("Score: {0}", score.Score);
     }
     else
     {
         Console.WriteLine("Failed: {0}", score.Message);
     }
     var report = spamChecker.GetReport(email);
     if (report.Success)
     {
         Console.WriteLine("Score: {0}\nReport: {1}", report.Score, report.Report);
     }
     else
     {
         Console.WriteLine("Failed: {0}", report.Message);
     }
 }