public void postInitialProcessDocument_controller_method_end_to_end_test_with_a_valid_request() //testing regular response { //arrange PostInitialProcessDocumentRequest requestObject = MatProcessDataHelper.CreatePostInitialProcessDocumentRequestObject(); var expectedResponse = new PostInitialProcessDocumentResponse(requestObject, requestObject.processRef, DateTime.Now); //act var controllerResponse = _processDataController.PostInitialProcessDocument(requestObject); var result = (ObjectResult)controllerResponse; var resultContent = (PostInitialProcessDocumentResponse)result.Value; //assert //check if the doc got inserted var documentFromDB = BsonSerializer.Deserialize <MatProcessData>(_dbcontext.getCollection().FindAsync(Builders <BsonDocument> .Filter.Eq("_id", requestObject.processRef)).Result.FirstOrDefault()); Assert.NotNull(documentFromDB); Assert.AreEqual(requestObject.processRef, documentFromDB.Id); Assert.NotNull(documentFromDB.ProcessType); Assert.AreEqual(requestObject.processType.value, documentFromDB.ProcessType.value); Assert.AreEqual(requestObject.processType.name, documentFromDB.ProcessType.name); Assert.AreEqual(requestObject.processDataSchemaVersion, documentFromDB.ProcessDataSchemaVersion); //check the controller response Assert.NotNull(controllerResponse); Assert.IsInstanceOf <ObjectResult>(result); Assert.NotNull(result); Assert.IsInstanceOf <PostInitialProcessDocumentResponse>(result.Value); Assert.NotNull(result.Value); Assert.AreEqual(expectedResponse.ProcessRef, resultContent.ProcessRef); Assert.AreEqual(expectedResponse.Request.processRef, resultContent.Request.processRef); //check status code Assert.AreEqual(201, result.StatusCode); }
public void given_a_valid_request_when_postinitialprocessdocument_controller_method_is_called_then_it_returns_a_response_that_resource_was_created() //temporary test until actual implementation will be worked on. { //arrange int expectedStatusCode = 201; PostInitialProcessDocumentRequest requestObject = MatProcessDataHelper.CreatePostInitialProcessDocumentRequestObject(); _mockValidatorPost.Setup(v => v.Validate(It.IsAny <PostInitialProcessDocumentRequest>())).Returns(new FV.ValidationResult()); //set up mock validation to return Validation with no errors. //act IActionResult controllerResponse = _processDataController.PostInitialProcessDocument(requestObject); var result = (ObjectResult)controllerResponse; var actualStatusCode = result.StatusCode; //assert Assert.NotNull(controllerResponse); Assert.NotNull(result); Assert.AreEqual(expectedStatusCode, actualStatusCode); }