Example #1
0
        public void GetBeneficiarysPaged_Success_Test()
        {
            // Arrange
            string searchTerm = "";
            int    pageIndex  = 0;
            int    pageSize   = 10;

            // list
            IList <R_Beneficiary> list = new List <R_Beneficiary>();

            for (int i = 1; i <= pageSize; i++)
            {
                list.Add(SampleBeneficiary(i));
            }

            // create mock for repository
            var mock = new Mock <IBeneficiaryRepository>();

            mock.Setup(s => s.GetBeneficiarys(Moq.It.IsAny <string>(), Moq.It.IsAny <int>(), Moq.It.IsAny <int>())).Returns(list);

            // service
            BeneficiaryService beneficiaryService = new BeneficiaryService();

            BeneficiaryService.Repository = mock.Object;

            // Act
            var            resultList = beneficiaryService.GetBeneficiarys(searchTerm, pageIndex, pageSize);
            BeneficiaryDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.BeneficiaryId);
            Assert.AreEqual(10, resultList.Count);
        }
Example #2
0
        public void GetBeneficiarys_Success_Test()
        {
            // Arrange
            R_Beneficiary beneficiary = SampleBeneficiary(1);

            IList <R_Beneficiary> list = new List <R_Beneficiary>();

            list.Add(beneficiary);

            // create mock for repository
            var mock = new Mock <IBeneficiaryRepository>();

            mock.Setup(s => s.GetBeneficiarys()).Returns(list);

            // service
            BeneficiaryService beneficiaryService = new BeneficiaryService();

            BeneficiaryService.Repository = mock.Object;

            // Act
            var            resultList = beneficiaryService.GetBeneficiarys();
            BeneficiaryDTO result     = resultList.FirstOrDefault();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.BeneficiaryId);
        }