コード例 #1
0
        public void Post_valid_data_returns_created_at_route()
        {
            // arrange
            var validViewModel = new WorkAssignmentVM();
            // act
            var result = _controller.Post(validViewModel);

            //assert
            Assert.IsInstanceOfType(result.Result, typeof(CreatedAtActionResult));
        }
コード例 #2
0
        public void Put_invalid_data_returns_bad_request()
        {
            // Arrange
            var invalidViewModel = new WorkAssignmentVM();

            _controller.ModelState.AddModelError("hourlyWage", "Required");
            // Act
            var result = _controller.Put(invalidViewModel.id, invalidViewModel);

            // Assert
            Assert.IsInstanceOfType(result.Result, typeof(BadRequestObjectResult));
        }
コード例 #3
0
        public void Post_valid_data_returns_new_record_in_data_object()
        {
            // arrange
            var validViewModel = new WorkAssignmentVM();
            // act
            var result            = _controller.Post(validViewModel).Result as ObjectResult;
            var returnedViewModel = UnitTestExtensions.ExtractFromDataObject <WorkAssignmentVM>(result?.Value);

            //assert
            Assert.IsInstanceOfType(returnedViewModel, typeof(WorkAssignmentVM));
            Assert.IsTrue(UnitTestExtensions.HasDataProperty(result));
        }