Exemplo n.º 1
0
        public void ShouldSendAlertWhenLegacySystemUpdate(bool isLegacySystemUpdate)
        {
            // Arrange.
            var serviceBus = new Mock <IServiceBus>();

            var strategy = new ApplicationStatusAlertStrategyBuilder()
                           .With(serviceBus)
                           .Build();

            var summary = new ApplicationStatusSummaryBuilder(ApplicationStatuses.Successful)
                          .IsLegacySystemUpdate(isLegacySystemUpdate)
                          .Build();

            // Act.
            strategy.Send(ApplicationStatuses.Unknown, summary);

            // Assert.
            var times = isLegacySystemUpdate ? Times.Once() : Times.Never();

            serviceBus.Verify(mock => mock
                              .PublishMessage(It.IsAny <ApplicationStatusChanged>()), times);
        }
Exemplo n.º 2
0
        public void ShouldSendWellFormedAlert()
        {
            // Arrange.
            const ApplicationStatuses currentStatus = ApplicationStatuses.Submitted;
            const ApplicationStatuses newStatus     = ApplicationStatuses.Successful;

            const int    legacyApplicationId = 3456789;
            const string unsuccessfulReason  = "You do not have the required grades";

            ApplicationStatusChanged applicationStatusChanged = null;

            var serviceBus = new Mock <IServiceBus>();

            serviceBus.Setup(mock => mock
                             .PublishMessage(It.IsAny <ApplicationStatusChanged>()))
            .Callback <ApplicationStatusChanged>(each =>
            {
                applicationStatusChanged = each;
            });

            var strategy = new ApplicationStatusAlertStrategyBuilder()
                           .With(serviceBus)
                           .Build();

            var summary = new ApplicationStatusSummaryBuilder(newStatus)
                          .WithLegacyApplicationId(legacyApplicationId)
                          .WithUnsuccessfulReason(unsuccessfulReason)
                          .Build();

            // Act.
            strategy.Send(currentStatus, summary);

            // Assert.
            applicationStatusChanged.Should().NotBeNull();
            applicationStatusChanged.LegacyApplicationId.Should().Be(legacyApplicationId);
            applicationStatusChanged.ApplicationStatus.Should().Be(newStatus);
            applicationStatusChanged.UnsuccessfulReason.Should().Be(unsuccessfulReason);
        }
Exemplo n.º 3
0
        public void ShouldSendAlertWhenApplicationStatusHasChangedToSuccessfulOrUnsuccessful(
            ApplicationStatuses currentStatus,
            ApplicationStatuses newStatus,
            bool shouldSendAlert)
        {
            // Arrange.
            var serviceBus = new Mock <IServiceBus>();

            var strategy = new ApplicationStatusAlertStrategyBuilder()
                           .With(serviceBus)
                           .Build();

            var summary = new ApplicationStatusSummaryBuilder(newStatus)
                          .Build();

            // Act.
            strategy.Send(currentStatus, summary);

            // Assert.
            var times = shouldSendAlert ? Times.Once() : Times.Never();

            serviceBus.Verify(mock => mock
                              .PublishMessage(It.IsAny <ApplicationStatusChanged>()), times);
        }