public void ApiAllSecuritiesMfExceptionExpectedMoqTest() { var moqsecurityrepository = new Mock<ISecuritiesMfRepository>(); IQueryable<SecurityMutualFundDto> securityMutualFundDtos = GetsecuritiesMfsList().AsQueryable(); moqsecurityrepository.Setup(x => x.GetListSecurityMf()).Throws<ArgumentNullException>(); var apicontroller = new SecuritiesWebApiMfController(moqsecurityrepository.Object); var secmfs = apicontroller.GetIQueryable(); Assert.IsInstanceOf<IQueryable<SecurityMutualFundDto>>(secmfs); moqsecurityrepository.VerifyAll(); }
public void ApiAllSecuritiesMfNoExceptionMoqTest() { var moqsecurityrepository = new Mock<ISecuritiesMfRepository>(); IQueryable<SecurityMutualFundDto> securityMutualFundDtos = GetsecuritiesMfsList().AsQueryable(); moqsecurityrepository.Setup(x => x.GetListSecurityMf()).Returns(securityMutualFundDtos.AsQueryable()); var apicontroller = new SecuritiesWebApiMfController(moqsecurityrepository.Object); var secmfs = apicontroller.GetIQueryable(); Assert.AreEqual(secmfs.Count(),securityMutualFundDtos.Count()); Assert.IsNotNull(secmfs); Assert.IsInstanceOf<IQueryable<SecurityMutualFundDto>>(secmfs); moqsecurityrepository.VerifyAll(); }
public void ApiSingleSecurityMfNoExceptionMoqTest() { var moqsecurityrepository = new Mock<ISecuritiesMfRepository>(); SecurityMutualFundDto securityMutualFundDto = GetsecuritiesMfsList().FirstOrDefault(); moqsecurityrepository.Setup(x => x.GetSecurityMfBySymbol("Demo1")).Returns(securityMutualFundDto); var apicontroller = new SecuritiesWebApiMfController(moqsecurityrepository.Object); var secmf = apicontroller.GetobjSecurityMutualFundDto("Demo1"); if (securityMutualFundDto != null) Assert.AreEqual(secmf.Id, securityMutualFundDto.Id); Assert.IsNotNull(secmf); Assert.IsInstanceOf<SecurityMutualFundDto>(secmf); moqsecurityrepository.VerifyAll(); }