public void ShouldCreateNewCoversationOnSend()
        {
            //Arrange:
            List <PrivateMessageBoard> conversations = new List <PrivateMessageBoard>();
            ConversationViewModel      conversation  = new ConversationViewModel {
                LastMessage = "Something", OtherID = "OtherID",
            };

            mockPrivateMessageBoardRepo.Setup(x => x.Insert(
                                                  It.Is <PrivateMessageBoard>(m => m.Message == "Something")))
            .Callback(() => conversations.Add(new PrivateMessageBoard {
                Message = "Something"
            }));
            //-----------//

            //Act:
            IDogOwnerService dogService = InitializeNewService();
            bool             isItTrue   = dogService.AddConversation(appUser.Id, conversation);

            //-----------//

            //Assert:
            mockPrivateMessageBoardRepo.Verify(mock => mock.Insert(
                                                   It.IsAny <PrivateMessageBoard>()), Times.Once);

            mockUnitOfWork.Verify(mock => mock.Commit(), Times.Once);

            Assert.That(conversations.Count, Is.EqualTo(1));
            Assert.That(isItTrue, Is.True);
            //-----------//
        }
Exemple #2
0
        public ActionResult SubmitConversation(PrivateConversationBetweenTwoUsers conversation)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            else
            {
                string userId = User.Identity.GetUserId();

                if (dogOwnerService.AddConversation(userId, conversation.NewConversation))
                {
                    return(Json(true));
                }
                else
                {
                    return(Json(false));
                }
            }
        }