Skip to content

Commit

Permalink
adding more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hkf-tech committed Aug 27, 2021
1 parent e580b79 commit 388ec4f
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,51 @@ public void ThenTheViewIsReturned()
Assert.IsNotNull(actual);
Assert.IsAssignableFrom<ViewResult>(actual);
}

[Test]
public void ThenTheViewModelIsMappedCorrectly()
{
//Act
var result = _homeController.TermsAndConditions("returnUrl", "hashedId");

//Assert
var viewResult = (ViewResult)result;
var viewModel = viewResult.Model;

Assert.IsInstanceOf<TermsAndConditionViewModel>(viewModel);
var termsAndConditionViewModel = (TermsAndConditionViewModel)viewModel;

Assert.AreEqual("returnUrl", termsAndConditionViewModel.ReturnUrl);
Assert.AreEqual("hashedId", termsAndConditionViewModel.HashedAccountId);
}


[Test]
public async Task ThenIsRedirectedToEmployerTeamController()
{
var termsAndConditionViewModel = new TermsAndConditionViewModel() { HashedAccountId = "HashedId", ReturnUrl = "EmployerTeam" };
//Act
var result = await _homeController.TermsAndConditions(termsAndConditionViewModel);

//Assert
var redirectResult = (RedirectToRouteResult)result;

Assert.AreEqual("Index", redirectResult.RouteValues["action"].ToString());
Assert.AreEqual("EmployerTeam", redirectResult.RouteValues["controller"].ToString());
}

[Test]
public async Task ThenIsRedirectedToHomeController()
{
var termsAndConditionViewModel = new TermsAndConditionViewModel() { HashedAccountId = "HashedId", ReturnUrl = "Home" };
//Act
var result = await _homeController.TermsAndConditions(termsAndConditionViewModel);

//Assert
var redirectResult = (RedirectToRouteResult)result;

Assert.AreEqual("Index", redirectResult.RouteValues["action"].ToString());
Assert.AreEqual("Home", redirectResult.RouteValues["controller"].ToString());
}
}
}

0 comments on commit 388ec4f

Please sign in to comment.