コード例 #1
0
        public void ShouldCallNotificationsBroker()
        {
            // given
            var          zServiceMock = new Mock <IZService>();
            Notification notification = new Filler <Notification>().Create();

            NotificationResponse notificationResponse = new Filler <NotificationResponse>().Create();

            // when
            zServiceMock.Setup(broker => broker.SendNotification(notification))
            .Returns(notificationResponse);

            // should
            var bService = new BService(zServiceMock.Object);

            bService.DoStuffB(notification);

            zServiceMock.Verify(broker =>
                                broker.SendNotification(notification),
                                Times.Once);
        }
コード例 #2
0
        public void ShouldCallXyzServiceToSendNotification()
        {
            // given
            var             xyzServiceMock = new Mock <IXYZService>();
            ABCNotification notification   = new Filler <ABCNotification>().Create();

            ABCNotificationResponse notificationResponse =
                new Filler <ABCNotificationResponse>().Create();

            xyzServiceMock.Setup(broker => broker.SendNotification(notification))
            .Returns(notificationResponse);

            // when
            var bService = new BService(xyzServiceMock.Object);

            bService.DoStuffB(notification);

            // then
            xyzServiceMock.Verify(
                broker => broker.SendNotification(notification),
                Times.Once);
        }