Exemple #1
0
        public async void GetAllMessages_Returns_OK()
        {
            var query = new MessagesController(context);

            var result = await query.GetMessagesInCase(0); // async

            Assert.IsType <ActionResult <IEnumerable <Messages> > >(result);
        }
Exemple #2
0
        public async void GetAllMessages_Check_First_And_Last_In_Case_1()
        {
            var query = new MessagesController(context);

            var result = await query.GetMessagesInCase(1);  // async

            Assert.Equal("Comment1 Case1", result.Value.First().Comment);
            Assert.Equal("Comment3 Case1", result.Value.Last().Comment);
        }
Exemple #3
0
        public async void GetAllMessages_In_Case_2()
        {
            var query = new MessagesController(context);

            var result = await query.GetMessagesInCase(2);  // async

            Assert.Equal(4, result.Value.ToList().Count);
            Assert.Equal(4, result.Value.Count());
        }
Exemple #4
0
        public async void Check_All_Received()
        {
            var query = new MessagesController(context);

            var result = await query.GetMessagesInCase(0);  // async

            Assert.Equal(7, result.Value.ToList().Count);
            Assert.Equal(7, result.Value.Count());
        }
Exemple #5
0
        public async void PostMessage_Returns_OK()
        {
            var query = new MessagesController(context);

            var newMessage = new Messages {
                Id = 8, Comment = "Comment4 Case2", CaseId = 2, UserId = "abc", IsEmployee = true
            };

            var result = await query.PostMessages(newMessage); // async

            var added = await query.GetMessagesInCase(0);      // async

            Assert.IsType <ActionResult <Messages> >(result);
            Assert.IsType <CreatedAtActionResult>(result.Result);
        }
Exemple #6
0
        public async void PostMessages_Add()
        {
            var query = new MessagesController(context);

            var newMessage = new Messages {
                Id = 8, Comment = "Comment4 Case2", CaseId = 2, UserId = "abc", IsEmployee = true
            };

            var result = await query.PostMessages(newMessage); // async

            var added = await query.GetMessagesInCase(0);      // async

            var singleReturnedMessage = added.Value.First(x => x.Id == 8);

            var resultGoodRequest = Assert.IsType <CreatedAtActionResult>(result.Result);
            var addedGoodRequest  = Assert.IsType <Messages>(singleReturnedMessage);

            Assert.Equal(newMessage, singleReturnedMessage);
            Assert.Equal(newMessage, resultGoodRequest.Value);
            Assert.Equal(newMessage, addedGoodRequest);
        }