Esempio n. 1
0
        public void TestGetAllMessages()
        {
            _mediatrMock
            .Setup(m => m.Send(It.IsAny <GetAllMessagesCommand>(), It.IsAny <CancellationToken>()))
            .ReturnsAsync(new GetAllMessagesResponse()
            {
                SmsMessages = new List <SmsMessages>()
                {
                    new SmsMessages()
                    {
                        MessageContent = "hello",
                        Result         = 1,
                        SmsMessagesId  = 1
                    },
                    new SmsMessages()
                    {
                        MessageContent = "hello 2",
                        Result         = 1,
                        SmsMessagesId  = 2
                    }
                }
            });

            var result = _instance.GetAllMessages();


            var okResult = result.Result as OkObjectResult;

            Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode);
        }
Esempio n. 2
0
        protected void LoadItems()
        {
            if (!HasEditPermission)
            {
                dgMessages.Columns[dgMessages.Columns.Count - 1].Visible = false;
            }

            List <MessageUI> items = MessagesController.GetAllMessages("");//txtSearch.Text.Trim());

            //bool isSearchActive;
            //if (!bool.TryParse(hfIsSearchActive.Value, out isSearchActive)) isSearchActive = false;

            //dgMessages.VirtualItemCount = items.Count;
            //if (dgMessages.VirtualItemCount == 0)
            //{
            //    phHasItems.Visible = false;
            //    phHasNoItems.Visible = true;
            //    lblNoItems.Text = isSearchActive ? MessagesStrings.GetText(@"MessageNoMessagesFound") : MessagesStrings.GetText(@"MessageNoDataHere");
            //}
            //else
            //{
            //    phHasItems.Visible = true;
            //    phHasNoItems.Visible = false;

            //    if (dgMessages.PageSize * dgMessages.CurrentPageIndex > dgMessages.VirtualItemCount)
            //    {
            //        dgMessages.CurrentPageIndex = 0;
            //        hfCurrentPageIndex_dgMessages.Value = dgMessages.CurrentPageIndex.ToString();
            //    }
            //    items.GetRange(dgMessages.PageSize * dgMessages.CurrentPageIndex, (dgMessages.PageSize > items.Count ? items.Count : dgMessages.PageSize));
            //LimitRows(dgMessages.PageSize).OffsetRows(dgMessages.PageSize * dgMessages.CurrentPageIndex);
            BindList(items);
            //}
        }
        public void GetAll_ShouldReturnSuccess(int messageCount)
        {
            for (var i = 0; i < messageCount; i++)
            {
                context.Message.Add(TestData.CreateDbMessage(i.ToString(), "test description", 0, Guid.NewGuid(), true, false));
            }
            context.SaveChanges();

            var result = controller.GetAllMessages() as ObjectResult;

            result.Should().BeOfType <OkObjectResult>();
            result.Should().NotBeNull();
            var models = result.Value as ICollection <Models.Message>;

            models.Should().NotBeNull();
            models.Count().Should().Be(messageCount);
        }
        public void GetAll_ShouldReturnBadRequest()
        {
            var mockContext = new Mock <HubDbContext>(options);

            mockContext.Setup(m => m.Message).Throws(new Exception());
            var badController = new MessagesController(mockContext.Object, logger.Object, mapper);

            var result = badController.GetAllMessages() as ObjectResult;

            result.StatusCode.Should().Be(400);
            result.Should().BeOfType <BadRequestObjectResult>();
        }
Esempio n. 5
0
        public void Getting_all_messages_returns_200_OK()
        {
            var result = messagesController.GetAllMessages();

            Assert.IsType <OkObjectResult>(result);
        }