public async void AadharDetailsExists_Test() { //Arrange var AadharCarddummy = new AadharCard() { AadharNumber = 765678945634, FirstName = "AadharFName_Dummy", LastName = "AadharLName_Dummy", Dob = "19-04-1991", PhoneNumber = "+919885801218", Address = "Dummy_Address", State = "Dummy_State", Pincode = 500083, Gender = "Male" }; RepoMock.Setup(r => r.LoadAdharDetails(765678945634)).ReturnsAsync(AadharCarddummy); RegisterController user = new RegisterController(RepoMock.Object); //Act var result = await user.GetAadharDetails(765678945634); var okResult = result as ObjectResult; //Assert Assert.NotNull(okResult); Assert.True(okResult is OkObjectResult); Assert.IsType <AadharCard>(okResult.Value); Assert.Equal(StatusCodes.Status200OK, okResult.StatusCode); }
public async void AadharDetailsDoesntExist_Test() { //Arrange RepoMock.Setup(r => r.LoadAdharDetails(56464534576864)).ReturnsAsync(new AadharCard { }); RegisterController onlineVotingController = new RegisterController(RepoMock.Object); //Act var result = await onlineVotingController.GetAadharDetails(56464534576864) as ObjectResult; //Assert Assert.NotNull(result); Assert.True(result is OkObjectResult); Assert.IsType <AadharCard>(result.Value); Assert.Equal(StatusCodes.Status200OK, result.StatusCode); }