GetReport() public method

public GetReport ( string emailBody ) : SpamcheckResult
emailBody string
return SpamcheckResult
コード例 #1
0
        public void GetReport_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.GetReport("Email");

            //Assert
            mockPostmarkSpamcheckWebClient
                .AssertWasCalled(a => a.GetSpamcheckResult(Arg<SpamcheckScoreRequest>.Is.Anything));
        }
コード例 #2
0
        public void GetReport_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.GetReport("Email");

            //Assert
            Assert.AreEqual(true, result.Success);
            Assert.AreEqual("7.9/5.0\n", result.Score);
        }
コード例 #3
0
ファイル: Main.cs プロジェクト: smoak/postmark-spamcheck
 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);
     }
 }