Example #1
0
        public async void DoesValidatorPreventsFromSendingEmptyNotification()
        {
            var request   = new SendGlobalNotification("");
            var validator = new SendGlobalNotificationValidator();

            var result = await validator.ValidateAsync(request);

            result.IsValid.Should().BeFalse();
        }
Example #2
0
        public async void DoesValidatorPreventsFromSendingTooLongNotification()
        {
            var request   = new SendGlobalNotification(Enumerable.Repeat("A", 700).Aggregate((s1, s2) => s1 + s2));
            var validator = new SendGlobalNotificationValidator();

            var result = await validator.ValidateAsync(request);

            result.IsValid.Should().BeFalse();
        }
Example #3
0
        public void ShouldCorrectlySendNotificationToAllSubscribers()
        {
            var context            = new FakeDbContext();
            var mockPlatformClient = new Mock <IPlatformClient>();

            mockPlatformClient.Setup(x => x.PlatformId).Returns("DebugMessageService");
            var platformClients = new[]
            {
                mockPlatformClient.Object
            };
            var backgroundJobClient = new Mock <IBackgroundJobClient>();
            var handler             = new SendGlobalNotificationHandler(platformClients, context, backgroundJobClient.Object);
            var request             = new SendGlobalNotification("test");

            handler.Handle(request, CancellationToken.None);

            backgroundJobClient.Verify(x => x.Create(
                                           It.Is <Job>(job => job.Method.Name == "SendMessage" && ReferenceEquals(job.Args[0], "sample-subscriber") && ReferenceEquals(job.Args[1], "test")),
                                           It.IsAny <EnqueuedState>()));
        }