public async Task ProviderNotSupportedErrorWhenStatusProviderNotSupported()
        {
            //Arrange
            providerFactory.Setup(f => f.GetStatusProviderForCommand(It.IsAny <CreateNotificationCommand>()))
            .Returns((IStatusProvider)null);

            //Act
            var result = await handler.Handle(new CreateNotificationCommand(), cltToken);

            //Assert
            Assert.Contains(result.Errors, e => e is StatusProviderNotSupportedError);
        }
Esempio n. 2
0
        public async Task GiveWrongType_ShouldRaiseNotTypeExceptionAsync()
        {
            var sut = new CreateNotificationCommandHandler(_context, _mapper);

            var command = new CreateNotificationCommand()
            {
                Type = "WRONG TYPE"
            };

            await Should.ThrowAsync <NotTypeException>(() =>
                                                       sut.Handle(command, CancellationToken.None));
        }
Esempio n. 3
0
        public async Task GiveValidRequest_ShouldCreateNotification1()
        {
            var sut = new CreateNotificationCommandHandler(_context, _mapper);
            List <UserModel> toUserList = new List <UserModel>();

            toUserList.AddRange(new[]
            {
                new UserModel
                {
                    DisplayName = "User1",
                    UserId      = userId1
                },
                new UserModel
                {
                    DisplayName = "User2",
                    UserId      = userId2
                }
            });

            var command = new CreateNotificationCommand()
            {
                Type             = "Mention",
                ConversationId   = conversationId.ToString(),
                isRead           = false,
                MessageContent   = "@User -> test",
                MessageId        = "",
                TeamId           = teamId1.ToString(),
                RegUserId        = "",
                ToUser           = toUserList,
                ConversationName = "",
                URL = ""
            };

            await sut.Handle(command, CancellationToken.None);

            var result = _context.Notifications.Where(q => q.MessageContent == "@User -> test").ToList();

            result.ShouldNotBeNull();
            result.Count.ShouldBe(toUserList.Count());
            foreach (Notification nfc in result)
            {
                nfc.Type.ShouldBe("Mention");
                nfc.TeamId.ShouldBe(teamId1.ToString());
                nfc.isRead.ShouldBeFalse();
                nfc.Title.ShouldContain("mentioned you in a channel");
            }
        }