public async Task RunActivity_InvalidJsonThrowsError() { var invalidObjects = new dynamic[] { new { repository = new { name = "repository-validator-testing", owner = "test" } }, new { repository = new { name = "repository-validator-testing" } }, new { repository = new { name = "repository-validator-testing", owner = (object)null } }, new { repository = new { owner = new { login = "******" } } } }; foreach (var dynamic in invalidObjects) { var request = new HttpRequestMessage() { Content = new StringContent(JsonConvert.SerializeObject(dynamic), System.Text.Encoding.UTF8, "application/json"), }; var result = await RepositoryValidatorEndpoint.RepositoryValidatorTrigger(request, _mockDurableClient, Substitute.For <ILogger>()); Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode); await _mockDurableClient.DidNotReceive().StartNewAsync(Arg.Any <string>(), Arg.Any <object>()); _mockDurableClient.DidNotReceive().CreateCheckStatusResponse(Arg.Any <HttpRequestMessage>(), Arg.Any <string>()); } }