public async void Replace_WhenSelectorIsValid_ReturnsReplacedHtmlWith200StatusCode() { //Arrange var html = @"<body> <div> <p>John M</p> <p>Kelly T</p> <p>Ryan S</p> </div> </body>"; var htmlParserService = new Mock <IHtmlParserService>(); htmlParserService.Setup(s => s.ReplacePeopleNames(It.IsAny <string>())).ReturnsAsync(html); var htmlParserController = new HtmlParserController(htmlParserService.Object); //Act var response = await htmlParserController.ReplacePeopleNamesRandomly("//div//p"); var contentResult = response as ContentResult; //Assert Assert.NotNull(contentResult); Assert.Equal(StatusCodes.Status200OK, contentResult.StatusCode); }
public async void Replace_WhenSelectorIsEmpty_Returns400BadRequest() { //Arrange var htmlParserService = new Mock <IHtmlParserService>(); var htmlParserController = new HtmlParserController(htmlParserService.Object); //Act var response = await htmlParserController.ReplacePeopleNamesRandomly(""); var badRequestResult = response as BadRequestResult; //Assert Assert.NotNull(badRequestResult); Assert.Equal(StatusCodes.Status400BadRequest, badRequestResult.StatusCode); }