コード例 #1
0
        public void TopicController_Put_WhenTheTopicIsUpdatedSuccessfully_WillReturnAnOKStatusAndASuccessMessage()
        {
            var controller = new TopicController(_topicsRepository.Object);

            SetUpHttpRequestParameters(controller);
            var response = controller.Put(new Topic
            {
                Name      = "Visual Studio on a Mac",
                Tutorials = new List <Tutorial> {
                }
            });

            Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
            ExpandoObject expando;

            Assert.IsTrue(response.TryGetContentValue(out expando));
            var expandoDict = (IDictionary <string, object>)expando;

            Assert.AreEqual("topic is updated successfully", expandoDict["message"]);
            _topicsRepository.Verify(t => t.Update(It.IsAny <Topic>()), Times.Once());
            _topicsRepository.Verify(c => c.Save(), Times.Once());
        }
コード例 #2
0
        public void PutReturnsBadRequest_TopicNotExistOnDatabase()
        {
            var result = controller.Put(Guid.NewGuid(), "Nome put");

            Assert.IsType <BadRequestObjectResult>(result.Result);
        }