public void Filter_TowAudit_Tests() { //Set Data #region Data int towID = 1; int mrmUserId = 25; string networkLogin = "******"; string FY = "2015"; string filter = ""; DataSourceResult result = new DataSourceResult(); TowAuditTrailExportModel towAuditViewModel = new TowAuditTrailExportModel() { }; List <TowAuditTrailExportModel> lstAuditModel = new List <TowAuditTrailExportModel>(); TowAuditTrailExportModel towAuditViewModelOnAir = new TowAuditTrailExportModel { BudgetType = "On Air" }; TowAuditTrailExportModel towAuditViewModelOffAir = new TowAuditTrailExportModel { BudgetType = "Off Air" }; TowAuditTrailExportModel towAuditViewModelPaidMedia = new TowAuditTrailExportModel { BudgetType = "Paid Media" }; lstAuditModel.Add(towAuditViewModelOnAir); lstAuditModel.Add(towAuditViewModelOffAir); lstAuditModel.Add(towAuditViewModelPaidMedia); #endregion //Mock #region Mock //Type of Service Mock mocktypeOfWorkRepository.Setup(x => x.GetTowAuditExport(It.IsAny <int>())).Returns(lstAuditModel.AsQueryable()); //Budget Service instance var budgetService = new BudgetServiceMock(unitOfWork: null, budget: null, channel: null, userChannel: null, loggerService: null, iTypeOfWork: mocktypeOfWorkRepository.Object, iFamilyProductIssueTowDeliverableRepository: null, budgetByChannel: null, iBudgetTypeTOWRepository: null, budgetByCategory: null , iBudgetByCategoryRollup: null, _ITypeOfWork_DeliverableCategory: null, _iForecastBudgetTypeCalendarTOWRepository: null, _iCalendarRepository: null, iTypeOfWorkCategoryRepository: null, iWBSFiscalYear_ChannelRepository: null, iBudgetTypeRepository: null); //Budget Controller Mock var BudgetController = new BudgetController(userService: null, loggerService: null, budgetService: budgetService, unitOfWork: null, productService: null, deliverableService: null, deliverableServiceV2: null, propertyService: null); #endregion //Assertions #region Assertions //Assert BudgetService Method Call var towAuditResults = budgetService.GetTowAuditExport(towID); mockbudgetService.Verify(); Assert.IsNotNull(towAuditResults);//Result is not Null Assert.AreEqual(towAuditResults.Count(), 3); var filteredModel = towAuditResults.Where(x => x.BudgetType == "On Air"); Assert.IsNotNull(towAuditResults);//Result is not Null Assert.AreEqual(filteredModel.Count(), 1); //Assertion of Controller method filter = "" + "|" + "Off Air" + "|" + "" + "|" + "false"; //Passing test data to filter for OnAir records var offAirResult = BudgetController.GetTowAuditKendo(towID, filter, mrmUserId, networkLogin, ""); Assert.IsNotNull(offAirResult.Data); Assert.AreEqual(offAirResult.Total, 1); filter = ""; var noFilterResult = BudgetController.GetTowAuditKendo(towID, filter, mrmUserId, networkLogin, ""); Assert.IsNotNull(noFilterResult.Data); Assert.AreEqual(noFilterResult.Total, 3); #endregion }