public void Run() { // Arrange var toDo = new ToDo { Description = $"description-{Guid.NewGuid()}" }; // Act var actionResult = Function2.Run(toDo, _logger); // Assert Assert.IsType <OkObjectResult>(actionResult); var okObjectResult = (OkObjectResult)actionResult; Assert.IsType <ToDo>(okObjectResult.Value); toDo = (ToDo)okObjectResult.Value; var expectedDataStore = nameof(ToDoSample2DataStore); Assert.Equal(expectedDataStore, toDo.DataStore); }
public async Task Run_CosmosDbReturnsNoDocument_Return404NotFound() { //arrange var mockHttpRequest = MockHttpRequestGenerator.CreateWithBodyString("STARTED"); //act var actionResult = await Function2.Run(mockHttpRequest.Object, null, _mockLogger); //assert Assert.IsTrue(_mockLogger.GetLogs().Where(m => m.Contains(UserFriendlyMessages.DocumentNotFound)).Count() == 1); Assert.IsInstanceOfType(actionResult, typeof(NotFoundObjectResult)); StringAssert.Contains(((NotFoundObjectResult)actionResult).Value.ToString(), UserFriendlyMessages.DocumentNotFound); }
public async Task Run_BodyDoesNotContainSTARTED_Return400BadRequest(string body) { //arrange var mockHttpRequest = MockHttpRequestGenerator.CreateWithBodyString(body); //act var actionResult = await Function2.Run(mockHttpRequest.Object, new IntermediaryServiceDocument(), _mockLogger); //assert Assert.IsTrue(_mockLogger.GetLogs().Where(m => m.Contains(UserFriendlyMessages.UnexpectedBodyContent)).Count() == 1); Assert.IsInstanceOfType(actionResult, typeof(BadRequestObjectResult)); StringAssert.Contains(((BadRequestObjectResult)actionResult).Value.ToString(), UserFriendlyMessages.UnexpectedBodyContent); }