Пример #1
0
            public void MarkMulipleMessagesAsUnreadIsSuccessful()
            {
                // Arrange
                var stubMessageDao = new Mock<IMessageDao>();
                var mockMessageEventDao = new Mock<IMessageEventDao>();
                var notificationManager = new NotificationManager 
                { 
                    MessageDao = stubMessageDao.Object,
                    MessageEventDao = mockMessageEventDao.Object
                };

                var businessId = 1;

                var message1 = MessageBuilder.BuildSimple(businessId);
                var message2 = MessageBuilder.BuildSimple(businessId, messageId: 2);

                var messageIds = new List<int>
                    {
                        message1.Id.Value,
                        message2.Id.Value
                    };

                stubMessageDao.Setup(b => b.ModifyMessageStatus(businessId, messageIds[0], MessageStatusEnum.Unread)).Returns(true);
                stubMessageDao.Setup(b => b.ModifyMessageStatus(businessId, messageIds[1], MessageStatusEnum.Unread)).Returns(true);
                mockMessageEventDao.Setup(e => e.CreateMessageEvent(messageIds[0], MessageStatusEnum.Unread));
                mockMessageEventDao.Setup(e => e.CreateMessageEvent(messageIds[1], MessageStatusEnum.Unread));

                // Act
                notificationManager.ChangeMessageStatusBulk(businessId, messageIds, MessageStatusEnum.Unread);

                // Assert
                mockMessageEventDao.VerifyAll();
                stubMessageDao.VerifyAll();
            }
Пример #2
0
            public void MarkSingleMessageAsReadIsSuccessful()
            {
                // Arrange
                var stubMessageDao = new Mock<IMessageDao>();
                var mockMessageEventDao = new Mock<IMessageEventDao>();
                var notificationManager = new NotificationManager 
                { 
                    MessageDao = stubMessageDao.Object,
                    MessageEventDao = mockMessageEventDao.Object
                };

                var businessId = 1;
                var message = MessageBuilder.BuildSimple(businessId, messageStatusEnum: MessageStatusEnum.Read);

                stubMessageDao.Setup(b => b.ModifyMessageStatus(businessId, message.Id.Value, MessageStatusEnum.Read)).Returns(true);
                mockMessageEventDao.Setup(b => b.CreateMessageEvent(message.Id.Value, MessageStatusEnum.Read));

                // Act
                bool result = notificationManager.ChangeMessageStatus(businessId, message.Id.Value, MessageStatusEnum.Read);

                // Assert
                Assert.IsTrue(result, "message status change wasn't done");
                stubMessageDao.VerifyAll();
                mockMessageEventDao.VerifyAll();
            }