public void Filter_BudgetTypeofWork_Tests() { //Set Data #region Data int typeOfWorkId = 1; int mrmUserId = 25; string networkLogin = "******"; string FY = "2015"; string filter = ""; MRM.DANG.Model.TypeOfWork tow = new MRM.DANG.Model.TypeOfWork { Id = 1, Name = "Test Name", FiscalYear = 2015, TypeOfWorkCategoryId = 10, TypeOfWorkStatus = new TypeOfWorkStatus() }; WBSFiscalYear_Channel wBSFiscalYear_Channel = new WBSFiscalYear_Channel { WBSNumber = "12345.123.234.001" }; //tow.WBSFiscalYear_Channel = wBSFiscalYear_Channel; List <Model.BudgetbyCategoryRollup> rollups = new List <Model.BudgetbyCategoryRollup>(); Model.BudgetbyCategoryRollup rollupOnAir = new Model.BudgetbyCategoryRollup { FiscalYear = 2015, BudgetTypeName = "On Air" }; Model.BudgetbyCategoryRollup rollupOffAir = new Model.BudgetbyCategoryRollup { FiscalYear = 2015, BudgetTypeName = "Off Air" }; Model.BudgetbyCategoryRollup rollupPaidMedia = new Model.BudgetbyCategoryRollup { FiscalYear = 2015, BudgetTypeName = "Paid Media" }; rollups.Add(rollupOnAir); rollups.Add(rollupOffAir); rollups.Add(rollupPaidMedia); List <CategoryBudgetRollupViewModel> BudgetRollUps = new List <CategoryBudgetRollupViewModel>(); CategoryBudgetRollupViewModel budgetRollup = new CategoryBudgetRollupViewModel() { towId = 1 }; BudgetRollUps.Add(budgetRollup); BudgetTypeOfWorkViewModel model = new BudgetTypeOfWorkViewModel(); model.BudgetRollups = BudgetRollUps; #endregion //Mock #region Mock //Budget Service Mock mockbudgetService.Setup(x => x.BudgetTypeOfWork(It.IsAny <int>())).Returns(new MRM.DANG.Model.TypeOfWork()); mockbudgetService.Setup(x => x.BudgetsByCategoryRollup(It.IsAny <int>(), It.IsAny <int>())).Returns(rollups); //TypeofService Mock mocktypeOfWorkRepository.Setup(x => x.GetBudgetTypeOfWorkModel(It.IsAny <int>())).Returns(tow); mocktypeOfWorkRepository.Setup(x => x.GetBudgetPreviousFYTypeOfWorkModel(It.IsAny <int>())).Returns(new PreviousFYTOWCustomModel()); //BudgetByCategoryRollupRepository Service Mock mockBudgetByCategoryRollupRepository.Setup(x => x.BudgetByCategoryRollupForTypeOfWork(It.IsAny <int>(), It.IsAny <int>())).Returns(rollups); 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: mockBudgetByCategoryRollupRepository.Object, _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 towResult = budgetService.BudgetTypeOfWork(typeOfWorkId); mockbudgetService.Verify(); mockBudgetByCategoryRollupRepository.Verify(); //Asserts service calls Assert.IsNotNull(tow); //Result is not Null Assert.AreEqual(tow, towResult); //Asserting the expected return object with dummy data Assert.AreEqual(tow.Id, towResult.Id); //Assert matching the return data with my input //Assert BudgetsByCategoryRollup var rollupResult = budgetService.BudgetsByCategoryRollup(tow.Id); Assert.IsNotNull(rollupResult); Assert.AreEqual(rollups, rollupResult); Assert.AreEqual(rollups.Count(), rollupResult.Count()); //TO Do review Assertions //model = BudgetController.BudgetTypeOfWork(typeOfWorkId, FY, filter, mrmUserId, networkLogin); //Assert.IsNotNull(model); //Assert.AreEqual(model.BudgetRollups.Count(), 4); //Assertions After applying filter //filter = "On Air" + "|" + "" + "|" + "" + "|" + "false"; //Passing test data to filter for OnAir records //model = BudgetController.BudgetTypeOfWork(typeOfWorkId, FY, filter, mrmUserId, networkLogin); //Assert.AreEqual(model.BudgetRollups.Count(), 2); #endregion }