public async Task IndexTestAsync(string Id) { // Act var response = await controller.Index(Id) as OkObjectResult; var result = JsonConvert.SerializeObject(response.Value); // Assert Assert.Contains("472", result); output.WriteLine(result); }
public void Get_ViewResult_Index_Test() { //Arrange DbSetup(); DetailsController controller = new DetailsController(mock.Object); //Act var result = controller.Index(); //Assert Assert.IsType <ViewResult>(result); }
public void Index_StateUnderTest_ExpectedBehavior(string Id) { // Arrange var controller = new DetailsController(configuration); controller.ControllerContext.HttpContext = new DefaultHttpContext(); controller.ControllerContext.HttpContext.Request.Headers["ApiKey"] = configuration["ApiKey"]; // Act var result = controller.Index(Id) as OkObjectResult; // Assert Assert.Contains("472", result.Value.ToString()); output.WriteLine(result.Value.ToString()); }
public void Details_Controller_Test_On_Index() { //Arrange var repo = Substitute.For <IRepository>(); ICollection <Detail> expectedDetails = new[] { new Detail(), }; repo.GetAll <Detail>().Returns(expectedDetails); var sut = new DetailsController(repo); //Act var actual = sut.Index().Result as ViewResult; //Assert Assert.IsInstanceOfType(actual, typeof(ViewResult)); var viewResult = actual; Assert.AreEqual(expectedDetails, viewResult.Model); }