public void IndexExceptionCase()
        {
            #region
            mockPurchaseRepository = new Mock <IPurchaseRepository>();

            // Prepare the return data for GetAllQuotation() method.
            var purchaseQuotationList = new List <PurchaseQuotation>();
            purchaseQuotationList.Add(new PurchaseQuotation {
                Purchase_Quote_Id = 1, Quotation_Status = "Completed"
            });

            // Mock up the GetAllQuotation() repository method with expected return values.
            mockPurchaseRepository.Setup(m => m.GetAllQuotation()).Returns(purchaseQuotationList);

            // Prepare the return data for the GetAddressList() method.
            var branchList = new List <BranchList>();
            branchList.Add(new BranchList {
                Branch_Id = 1, Branch_Name = "MADURAI MAIN"
            });

            // Mock up the GetAddressList() repository method with expected return value.
            //mockPurchaseRepository.Setup(m => m.GetAddressList()).Returns(branchList);

            purchaseController = new PurchaseController(mockPurchaseRepository.Object, mockManufacturerRepository.Object);
            #endregion

            // Now invoke the Index action.
            var actionResult = purchaseController.Index() as ViewResult;

            // Validate the expected result.
            ViewResult expectedResult = new ViewResult();
            Assert.AreEqual("Error", actionResult.ViewName);
        }
        public void Index()
        {
            /*
             *  First identify the repository methods which are invoked form Index action. Then Setup the mock
             *  for all the identified methods.
             *
             *  Then invoke the Controller's Index action with necessary input parameters and ensure that you have
             *  invoked the Index action for all the different cases (code blocks) available in that, which should
             *  cover all the blocks/statements in the Index action.
             *
             */
            #region Arrange
            // Prepare the return data for GetAllQuotation() method.
            var purchaseQuotationList = new List <PurchaseQuotation>();
            purchaseQuotationList.Add(new PurchaseQuotation {
                Purchase_Quote_Id = 1, Quotation_Status = "Completed"
            });

            // Mock up the GetAllQuotation() repository method with expected return values.
            mockPurchaseRepository.Setup(m => m.GetAllQuotation()).Returns(purchaseQuotationList);

            // Prepare the return data for the GetAddressList() method.
            var branchList = new List <BranchList>();
            branchList.Add(new BranchList {
                Branch_Id = 1, Branch_Name = "MADURAI MAIN"
            });

            // Mock up the GetAddressList() repository method with expected return value.
            mockPurchaseRepository.Setup(m => m.GetAddressList()).Returns(branchList);
            #endregion

            // Now invoke the Index action.
            var actionResult = purchaseController.Index() as ViewResult;

            // Validate the expected result.
            ViewResult expectedResult = new ViewResult();

            Assert.AreEqual(purchaseQuotationList, (actionResult.Model as PurchaseViewModels).PurchaseQuotationList);
            //Assert.AreEqual(branchList, (actionResult.Model as PurchaseViewModels).BranchList);
        }