예제 #1
0
        public void TestInquiryHandlers()
        {
            // given
            Inquiry.Inquiry inquiry = new Inquiry.Inquiry();
            inquiry.Username  = "******";
            inquiry.Recipient = "*****@*****.**";
            inquiry.Text      = "Can I haz cheezburger?";

            // room for potential additional test setup
            // mock interfaces instead of the classes
            var mockEmailHandler            = new Mock <IEmailHandler>();
            var mockPushNotificationHandler = new Mock <IPushNotificationHandler>();

            var services = new ServiceCollection()
                           .AddLogging()
                           .AddSingleton <InquiryService>()
                           .AddSingleton(mockEmailHandler.Object)
                           .AddSingleton(mockPushNotificationHandler.Object);

            var inquiryService = services
                                 .BuildServiceProvider()
                                 .GetRequiredService <InquiryService>();

            // when
            inquiryService.Create(inquiry);

            // then
            mockEmailHandler.Verify(e => e.SendEmail(inquiry));
            mockPushNotificationHandler.Verify(e => e.SendNotification(inquiry));
        }
예제 #2
0
 public virtual void SendEmail(Inquiry.Inquiry inquiry)
 {
     Console.WriteLine(string.Format("sending email for: {0}", inquiry.ToString()));
 }
예제 #3
0
 public IActionResult Create(Inquiry.Inquiry inquery)
 {
     //just for the testing purpose
     inquiryService.Create(inquery);
     return(Ok());
 }
 public virtual void SendNotification(Inquiry.Inquiry inquiry)
 {
     Console.WriteLine(string.Format("sending notification inquiry: {0}", inquiry.ToString()));
 }