Example #1
0
        public void Delete()
        {
            // Arrange
            ChatController controller = new ChatController();

            // Act
            controller.Delete(5);

            // Assert
        }
Example #2
0
        public async Task DeleteShouldReturnProperRedirect()
        {
            // Arrange
            var mockMessagesService = new Mock <IMessagesService>();
            var controller          = new ChatController(mockMessagesService.Object);

            // Act
            var result = await controller.Delete(0);

            // Assert
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", redirectToActionResult.ActionName);
        }
        public void DeleteChatsGetShowsCorrectData()
        {
            var clientRepository  = RepositoryHelper.RepositoryLocalWithOneClient;
            var chatRepository    = new LocalRepository <Contact>();
            var client            = clientRepository.All().First();
            var contactService    = new Mock <IContactService>();
            var restClient        = new Mock <IRestClient>();
            var userManager       = new Mock <IIdentityMembershipProvider>();
            var contactAutoRating = new Mock <IContactAutoRating>();


            var chat = new Contact
            {
                Id       = 1,
                ClientId = client.Id,
                Date     = new DateTime(2013 - 1 - 02)
            };
            var chatProperty = new ContactProperty()
            {
                Id    = 1,
                Type  = "Description",
                Value = "this is the description"
            };
            var chatProperty2 = new ContactProperty()
            {
                Id    = 1,
                Type  = "Email",
                Value = "*****@*****.**"
            };
            var chatProperty3 = new ContactProperty()
            {
                Id    = 1,
                Type  = "Phone",
                Value = "08123456"
            };

            chat.Property.Add(chatProperty);
            chat.Property.Add(chatProperty2);
            chat.Property.Add(chatProperty3);
            chatRepository.Add(chat);

            var claim = new Claim("test", "AnyId");

            userManager.Setup(um => um.GetRoles(It.IsAny <string>())).Returns(new List <string> {
                "mockRole"
            });

            var controller = new ChatController(
                chatRepository,
                clientRepository,
                contactService.Object,
                new ServerTime(),
                restClient.Object, userManager.Object, contactAutoRating.Object);

            ModelHelper.SetClaimAsCurrentUserForController(claim, controller);

            var result = controller.Delete(chat.Id) as ViewResult;
            var model  = result.Model as ChatViewModel;

            Assert.AreEqual(client.Name, model.ClientName);
            Assert.AreEqual(chat.Id, model.Id);
            Assert.AreEqual("*****@*****.**", model.Email);
            Assert.AreEqual("08123456", model.Phone);
        }