public void GivenTheAllocationReferenceContainsDeliverableGroupThatContainsFollowingDeliverables(string allocationReference, string deliverableGroupName, Table tblDeliverables) { var contractAllocation = _claimGroup.ContractAllocations.FirstOrDefault(x => x.AllocationReference == allocationReference); if (contractAllocation == null) { Assert.Fail($"Contract Allocation with Allocation Reference {allocationReference} is not found"); } var deliverables = tblDeliverables.Rows.Select(row => new Deliverable() { DeliverableCode = Convert.ToInt32(row["Deliverable Code"]), PlannedValue = Convert.ToDecimal(row["Deliverable Planned Value"]), ActualsToDateValue = Convert.ToDecimal(row["Deliverable Actuals to Date Value"]), ForecastRemainingDeliveryValue = Convert.ToDecimal(row["Deliverable Forecast Remaining Delivery Value"]), ExceptionalAdjustmentsValue = Convert.ToDecimal(row["Deliverable Exceptional Adjustments Value"]) }).ToList(); if (contractAllocation.DeliverableGroups == null) { contractAllocation.DeliverableGroups = new List <DeliverableGroup>(); } DeliverableGroup deliverableGroup = new DeliverableGroup(); deliverableGroup.DeliverableGroupName = deliverableGroupName; deliverableGroup.Deliverables = deliverables; contractAllocation.DeliverableGroups.Add(deliverableGroup); }
public void SentPrimaryTOWInfoToMediatorTest() { #region Data Setup DeliverableGroup testDeliverableGroup = new DeliverableGroup() { Code = "VID" }; Model.TypeOfWork typeOfWork1 = new Model.TypeOfWork() { Name = "Type Of Work A", Id = 1100 }; Model.TypeOfWork typeOfWork2 = new Model.TypeOfWork() { Name = "Type Of Work B", Id = 1101 }; Channel testChannel = new Channel() { Code = "DC" }; //Radio Disney Guid DeliverableBudgetUniqueID1 = Guid.NewGuid(); Guid DeliverableBudgetUniqueID2 = Guid.NewGuid(); WBSElement wbsElement1 = new WBSElement() { Id = 1, FullWBSNumber = "123456.011.001", TypeOfWorkId = 1100 }; WBSElement wbsElement2 = new WBSElement() { Id = 2, FullWBSNumber = "123456.011.002", TypeOfWorkId = 1101 }; wbsElement1.TypeOfWork = typeOfWork1; wbsElement2.TypeOfWork = typeOfWork2; DeliverableDate FPADate = new DeliverableDate() { Id = 1, DeliverableDateTypeId = 1, DateValue = new DateTime() }; DeliverableDate DueDate = new DeliverableDate() { Id = 2, DeliverableDateTypeId = 9, DateValue = new DateTime() }; List <DeliverableDate> deliverableDateList = new List <DeliverableDate>(); deliverableDateList.Add(FPADate); deliverableDateList.Add(DueDate); ActivityStatus activityStatus = new ActivityStatus() { Id = 39, IsActiveFlag = true, Code = "INPCC", }; TrackElement trk1 = new TrackElement() { Id = 1, ActivityStatusId = 39, HouseNumber = "MRM1403030766624", Name = "Textless Generic", ActualLength = 0.10m, IsActiveFlag = true }; TrackElement trk2 = new TrackElement() { Id = 2, ActivityStatusId = 39, HouseNumber = "MRM1403030766625", Name = "International Textless", ActualLength = 0.10m, IsActiveFlag = true }; DeliverableDate deliverableDate1 = new DeliverableDate() { Id = 1, DeliverableId = 140000 }; DeliverableDate deliverableDate2 = new DeliverableDate() { Id = 2, DeliverableId = 140000 }; DeliverableDateType deliverableDateType1 = new DeliverableDateType() { Id = 1, Code = "FPA" }; DeliverableDateType deliverableDateType2 = new DeliverableDateType() { Id = 2, Code = "DEL" }; FPADate.DeliverableDateType = deliverableDateType1; DueDate.DeliverableDateType = deliverableDateType2; Model.Deliverable testDeliverable = new Model.Deliverable() { Id = 140000, DeliverableTypeId = 94, //Affiliate Marketing ProducingDepartmentId = 84, //MRM Team Name = "Disney Channel Video Deliverable", DeliverableGroupId = 2, //Video DeliverableGroup = testDeliverableGroup, Channel = testChannel, DeliverableStatusId = 3, PlannedLengthId = 10, ClipDeliverMasterVendorId = 418 }; testDeliverable.PrimaryDeliverableBudgetUniqueID = DeliverableBudgetUniqueID1; testDeliverable.DeliverableDate = deliverableDateList; DeliverableStatus deliverableStatus = new DeliverableStatus() { Id = 2, Code = "INPCC", Name = "In Process" }; testDeliverable.DeliverableStatus = deliverableStatus; DeliverableBudget deliverableBud1 = new DeliverableBudget() { Id = 1, DeliverableId = 140000, MasterVendorId = 12 }; deliverableBud1.DeliverableBudgetUniqueID = DeliverableBudgetUniqueID1; deliverableBud1.WBSElement = wbsElement1; DeliverableBudget deliverableBud2 = new DeliverableBudget() { Id = 2, DeliverableId = 140000, MasterVendorId = 25 }; deliverableBud2.DeliverableBudgetUniqueID = DeliverableBudgetUniqueID2; deliverableBud2.WBSElement = wbsElement2; List <DeliverableBudget> deliverableBudgetList = new List <DeliverableBudget>(); deliverableBudgetList.Add(deliverableBud1); deliverableBudgetList.Add(deliverableBud2); testDeliverable.DeliverableBudget = deliverableBudgetList; ProductionMethodType productionMethodType1 = new ProductionMethodType() { Id = 1, Code = "PH", Name = "Post House" }; ProductionMethodType productionMethodType2 = new ProductionMethodType() { Id = 2, Code = "CS", Name = "Creative Services" }; List <ProductionMethodType> productionMethodTypeList = new List <ProductionMethodType>(); productionMethodTypeList.Add(productionMethodType1); productionMethodTypeList.Add(productionMethodType2); List <int> pmoList = new List <int>(); pmoList.Add(productionMethodTypeList.ElementAt(0).Id); pmoList.Add(productionMethodTypeList.ElementAt(1).Id); List <DeliverableDate> deldates = new List <DeliverableDate>(); deldates.Add(FPADate); deldates.Add(DueDate); testDeliverable.DeliverableDate = deldates; List <TrackElement> lstTrk = new List <TrackElement>(); lstTrk.Add(trk1); lstTrk.Add(trk2); testDeliverable.TrackElement = lstTrk; DeliverableBudgetViewModel deliverableBudget1 = new DeliverableBudgetViewModel() { DeliverableId = 140000, WBSNumber = "123456.123.001", MasterVendorId = 10, isPrimary = true, TowId = 1, BudgetTypeId = 3, FiscalYearId = 2016, BudgetGroupId = 55, DeliverableBudgetId = 1, UserId = 852, DeliverableBudgetUniqueID = DeliverableBudgetUniqueID1 }; deliverableBudget1.ProductionMethodTypeIds = pmoList; DeliverableBudgetViewModel deliverableBudget2 = new DeliverableBudgetViewModel() { DeliverableId = 140000, MasterVendorId = 15, isPrimary = false, TowId = 2, BudgetTypeId = 4, FiscalYearId = 2016, BudgetGroupId = 77, DeliverableBudgetId = 2, DeliverableBudgetUniqueID = DeliverableBudgetUniqueID2 }; deliverableBudget2.ProductionMethodTypeIds = pmoList; List <DeliverableBudgetViewModel> deliverableBudgetViewModelList = new List <DeliverableBudgetViewModel>(); deliverableBudgetViewModelList.Add(deliverableBudget1); deliverableBudgetViewModelList.Add(deliverableBudget2); DeliverableMultiWBSModel deliverableMultiWBSModel = new DeliverableMultiWBSModel() { DeliverableId = 140000, PrimaryDeliverableBudgetUniqueID = DeliverableBudgetUniqueID1, IsLaunchFlag = false }; deliverableMultiWBSModel.Budgets = deliverableBudgetList; DeliverableMultiWBSViewModel deliverableMultiWBSViewModel = new DeliverableMultiWBSViewModel() { DeliverableId = 140000, InitialBudgetAmount = 99, IsLaunchFlag = true, PrimaryDeliverableBudgetUniqueID = DeliverableBudgetUniqueID1, ClipDeliverMasterVendorId = 100, ProducingDepartmentId = 108, MarketingGroupChannelId = 1, Budgets = deliverableBudgetViewModelList, }; deliverableMultiWBSViewModel.Budgets = deliverableBudgetViewModelList; Deliverable_WBSElement deliverable_WBSElement = new Deliverable_WBSElement() { DeliverableId = 14000, Id = 1, }; deliverable_WBSElement.Deliverable = testDeliverable; MasterVendor masterVendor = new MasterVendor() { Id = 1, SAPVendorId = 25, MediatorVendorId = "795" }; PromoPlacementBody promoPlacementBody = new PromoPlacementBody(); PromoPlacementBody promoPlacementBodyResult = new PromoPlacementBody(); #endregion #region Mapper Mapper.CreateMap <Model.Deliverable, PromoPlacementBody>() .ForMember(i => i.ChannelCode, m => m.MapFrom(d => d.Channel.Code)) .ForMember(i => i.DeliverableId, m => m.MapFrom(d => d.Id)) .ForMember(i => i.DeliverableName, m => m.MapFrom(d => d.Name)) .ForMember(i => i.DeliverableStatusCode, m => m.MapFrom(d => d.DeliverableStatus.Code)) .ForMember(i => i.DeliverableTargetCode, m => m.MapFrom(d => d.Channel1.Code)) .ForMember(i => i.DeliverableTypeCode, m => m.MapFrom(d => d.DeliverableType.Code)) .ForMember(i => i.IsOffAir, m => m.MapFrom(d => d.IsOffChannelFlag)) .ForMember(i => i.FinalDueDate, m => m.MapFrom( d => d.DeliverableDate.FirstOrDefault( i => i.DeliverableDateType.Code == Core.Constants.DeliverableDateType.Final_Due) .DateValue)) .ForMember(i => i.FirstPromoAirDate, m => m.MapFrom( d => d.DeliverableDate.FirstOrDefault( i => i.DeliverableDateType.Code == Core.Constants.DeliverableDateType.FirstPromotionalAirDate).DateValue)) .ForMember(i => i.IsReissue, m => m.MapFrom(d => d.IsReIssueFlag)) //Updated for MRM-213 .ForMember(i => i.TOWId, m => m.MapFrom(d => d.DeliverableBudget.Where(x => x.DeliverableBudgetUniqueID == d.PrimaryDeliverableBudgetUniqueID).FirstOrDefault().WBSElement.TypeOfWorkId.Value)) .ForMember(i => i.TOWName, m => m.MapFrom(d => d.DeliverableBudget.Where(x => x.DeliverableBudgetUniqueID == d.PrimaryDeliverableBudgetUniqueID).FirstOrDefault().WBSElement.TypeOfWork.Name)) .ForMember(i => i.WBSNumber, m => m.MapFrom(d => FormatWBS(d.DeliverableBudget.Where(x => x.DeliverableBudgetUniqueID == d.PrimaryDeliverableBudgetUniqueID).FirstOrDefault()))) .ForMember(i => i.WriterProducer, m => m.MapFrom(d => FormatOwnerName(Core.Constants.UserTitle.WriterProducer, d) == string.Empty ? FormatOwnerName(Core.Constants.UserTitle.ProductionManager, d) : FormatOwnerName(Core.Constants.UserTitle.WriterProducer, d))) .ForMember(i => i.WriterProducerId, m => m.MapFrom(d => FormatNetworkLogin(Core.Constants.UserTitle.WriterProducer, d) == string.Empty ? FormatOwnerName(Core.Constants.UserTitle.ProductionManager, d) : FormatNetworkLogin(Core.Constants.UserTitle.WriterProducer, d))); #endregion #region Mocking mockDeliverableServiceV2.Setup(x => x.GetMasterVendorById(It.IsAny <int>())) .Returns(masterVendor); // Check for MediatorVendorId for SAP Vendor ID -- logic in GetVendorSAP() in IntergrationManager.cs mockIntegrationService.Setup(x => x.GetCommentsForDeliverable(It.IsAny <int>())) .Returns(new List <Comment>()); mockIntegrationService.Setup(x => x.GetTargetPlatforms(It.IsAny <List <int> >())) .Returns(new List <TargetPlatform>()); #endregion #region Service promoPlacementBody = Mapper.Map <Model.Deliverable, PromoPlacementBody>(testDeliverable); var integrationMock = new IntergrationManagerMock(deliverableV2Service: mockDeliverableServiceV2.Object, intergrationService: mockIntegrationService.Object); promoPlacementBodyResult = integrationMock.GetPromoPlacementForAssetManagement(testDeliverable, "SWNA\\TestLogin"); #endregion #region Assert Assert.IsFalse(promoPlacementBodyResult == null); Assert.IsTrue(promoPlacementBodyResult.DeliverableStatusCode == "INPCC"); Assert.IsTrue(promoPlacementBodyResult.VendorNumber == masterVendor.MediatorVendorId); Assert.IsTrue(promoPlacementBodyResult.TOWName == typeOfWork1.Name); Assert.IsTrue(promoPlacementBodyResult.WBSNumber == wbsElement1.FullWBSNumber); #endregion }
public void UpsertBillingWorkOrderTransactions_ForFY2017() { #region Data Setup WorkOrderTransaction workOrderTransaction1 = new WorkOrderTransaction() { TransactionNumber = "11111111", BillingAmount = 5000, CreatedBy = 496, Id = 1, WorkOrderId = 1, BeginDate = new DateTime(2017, 5, 19) }; WorkOrderTransaction workOrderTransactionExist = new WorkOrderTransaction() { TransactionNumber = "22222222", BillingAmount = 3000, CreatedBy = 496, Id = 2, BeginDate = new DateTime(2016, 5, 19) }; List <WorkOrderTransaction> workOrderTransactionList = new List <WorkOrderTransaction>(); workOrderTransactionList.Add(workOrderTransaction1); DeliverableGroup testDeliverableGroup = new DeliverableGroup() { Code = "VID"//Video }; Channel testChannel = new Channel() { Code = "ROM"//Radio Disney }; WBSElement wbsElement1 = new WBSElement() { Id = 1, FullWBSNumber = "123456.011.001", TypeOfWorkId = 1000, }; WBSElement wbsElement2 = new WBSElement() { Id = 2, FullWBSNumber = "123456.011.002", TypeOfWorkId = 1001, }; Deliverable testDeliverable = new Deliverable() { Id = 1, DeliverableTypeId = 94, //Affiliate Marketing ProducingDepartmentId = 84, //MRM Team Name = "Radio Disney Video Deliverable", //ChannelId = 10,//Radio Disney DeliverableGroupId = 2,//Video DeliverableGroup = testDeliverableGroup, Channel = testChannel, }; DeliverableBudget deliverableBudget1 = new DeliverableBudget() { DeliverableId = 1, Id = 100, WBSElement = wbsElement1, MasterVendorId = 418, Deliverable = testDeliverable, PHApplyPercent = 40 }; DeliverableBudget deliverableBudget2 = new DeliverableBudget() { DeliverableId = 1, Id = 101, WBSElement = wbsElement2, MasterVendorId = 418, Deliverable = testDeliverable, }; WorkOrder workOrder = new WorkOrder() { WorkOrderNumber = 1122, Id = 1, VendorId = 418, DeliverableId = 1, Deliverable = testDeliverable }; TypeOfWork tow = new TypeOfWork() { Id = 1, ChannelId = 1, FiscalYear = 2016 }; WBSFiscalYear_Channel wBSFiscalYear_Channel = new WBSFiscalYear_Channel() { FiscalYear = "2016", Id = 52, WBSNumber = "12345", CreatedBy = 496 }; List <WorkOrder> workOrderList = new List <WorkOrder>(); workOrderList.Add(workOrder); List <Deliverable> deliverableList = new List <Deliverable>(); deliverableList.Add(testDeliverable); List <DeliverableBudget> deliverableBudgetList = new List <DeliverableBudget>(); deliverableBudgetList.Add(deliverableBudget1); tow.DeliverableBudget = deliverableBudgetList; List <TypeOfWork> towList = new List <TypeOfWork>(); towList.Add(tow); List <WBSFiscalYear_Channel> wbsFiscalYear_ChannelList = new List <WBSFiscalYear_Channel>(); wbsFiscalYear_ChannelList.Add(wBSFiscalYear_Channel); //wBSFiscalYear_Channel.TypeOfWork = towList; List <int> deliverableBudgetIdList = new List <int>(); deliverableBudgetIdList.Add(deliverableBudget1.Id); Calendar calendar = new Calendar() { Id = 1, CalendarYear = "2016", FiscalYear = "2017" }; MRMUser user = new MRMUser() { Id = 496, UserName = "******" }; #endregion #region Mocking mockWorkOrderTransactionRepositry.Setup(i => i.GetSingle(It.IsAny <Expression <Func <WorkOrderTransaction, bool> > >())) .Returns(workOrderTransactionExist); mockWorkOrderRepository.Setup(i => i.GetAll()).Returns(workOrderList.AsQueryable()); mockDeliverableRepository.Setup(i => i.GetAll()).Returns(deliverableList.AsQueryable()); mockDeliverableBudgetRepository.Setup(i => i.GetAll()).Returns(deliverableBudgetList.AsQueryable()); mockTypeOfWorkRepository.Setup(i => i.GetAll()).Returns(towList.AsQueryable()); mockDeliverableRepository.Setup(i => i.CreateCrossoverDeliverable(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>())) .Returns(deliverableBudgetIdList.AsQueryable()); mockDeliverableBudgetRepository.Setup(i => i.GetByDeliverableBudgetId(It.IsAny <int>())) .Returns(deliverableBudget1); mockDeliverableBudgetRepository.Setup(i => i.Update(It.IsAny <DeliverableBudget>())); mockWorkOrderTransactionRepositry.Setup(i => i.Add(It.IsAny <WorkOrderTransaction>())); mockWorkOrderTransactionRepositry.Setup(i => i.Update(It.IsAny <WorkOrderTransaction>())); mockInvoiceLineRepository.Setup(i => i.GetSingle(It.IsAny <Expression <Func <InvoiceLine, bool> > >())) .Returns(() => null); mockUnitOfWork.Setup(i => i.Commit()); mockUserRepository.Setup(i => i.GetSingle(It.IsAny <Expression <Func <MRMUser, bool> > >())).Returns(user); mockCalendarRepository.Setup(i => i.GetSingle(It.IsAny <Expression <Func <Calendar, bool> > >())).Returns(calendar); mockWBSFiscalYear_ChannelRepository.Setup(i => i.GetAll()).Returns(wbsFiscalYear_ChannelList.AsQueryable()); #endregion #region Service var integrationService = new IntegrationServiceMock(workOrderRepository: mockWorkOrderRepository.Object, iBillingWorkOrderTransactionRepositry: mockWorkOrderTransactionRepositry.Object, iDeliverableRepository: mockDeliverableRepository.Object, iDeliverableBudgetRepository: mockDeliverableBudgetRepository.Object, iTypeOfWorkRepository: mockTypeOfWorkRepository.Object, iInvoiceLineRepository: mockInvoiceLineRepository.Object, unitOfWork: mockUnitOfWork.Object, iUserRepository: mockUserRepository.Object, iCalendarRepository: mockCalendarRepository.Object, iWBSFiscalYear_ChannelRepository: mockWBSFiscalYear_ChannelRepository.Object); bool result = integrationService.UpsertBillingWorkOrderTransactions(workOrderTransactionList); #endregion #region Asserts Assert.IsTrue(result == true); #endregion }
public void ContractRequestsGrid_Tests() { #region Data Deliverable deliverable1 = new Deliverable() { Id = 1403256, CreatedBy = 556, Name = "Test", ProducingDepartmentId = 1 }; Department dept1 = new Department() { Id = 1, Code = "PROG" }; DeliverableGroup deliverablegroup1 = new DeliverableGroup() { Id = 1, Code = "CR" }; DeliverableType deliverabletype1 = new DeliverableType() { Name = "CR", Id = 1 }; DeliverableStatus status = new DeliverableStatus() { Name = "Draft", Id = 1 }; DeliverableBudget delbudget = new DeliverableBudget() { CreatedBy = 556, EstimateCompleteAmount = 100, ActualAmount = 500, Id = 285, MasterVendorId = 61 }; MasterVendor msvendor = new MasterVendor() { Id = 61, CreatedBy = 556 }; string SAPVendorName = "SAP Vendor Name"; Vendor vendors = new Vendor() { Id = 61, Name = SAPVendorName }; msvendor.Vendor = vendors; delbudget.MasterVendor = msvendor; InvoiceLine invoice1 = new InvoiceLine() { Id = 1, Amount = 100 }; List <InvoiceLine> invoicelist = new List <InvoiceLine>(); invoicelist.Add(invoice1); delbudget.InvoiceLine = invoicelist; ActualsReconciliation arc = new ActualsReconciliation() { ActualAmount = 100, CreatedBy = 556, DeliverableBudgetId = 285 }; List <ActualsReconciliation> arclist = new List <ActualsReconciliation>(); arclist.Add(arc); delbudget.ActualsReconciliation = arclist; List <DeliverableBudget> delbudgetlist = new List <DeliverableBudget>(); delbudgetlist.Add(delbudget); DeliverableDate deldate = new DeliverableDate() { Id = 1, DeliverableId = 1403256 }; DeliverableDateType deldatetype = new DeliverableDateType() { Id = 1, Code = "DEL" }; deldate.DeliverableDateType = deldatetype; List <DeliverableDate> deldatelist = new List <DeliverableDate>(); deldatelist.Add(deldate); ContractRequest ctrreq = new ContractRequest() { ContractRequestProject = "CR", CreatedBy = 556 }; deliverable1.DeliverableGroup = deliverablegroup1; deliverable1.Department = dept1; deliverable1.DeliverableType = deliverabletype1; deliverable1.DeliverableStatus = status; deliverable1.DeliverableDate = deldatelist; deliverable1.ContractRequest = ctrreq; deliverable1.DeliverableBudget = delbudgetlist; List <Deliverable> deliverablelist = new List <Deliverable>(); deliverablelist.Add(deliverable1); List <CRDeliverableViewModel> viewModel = new List <CRDeliverableViewModel>(); #endregion #region Mock mockdeliverablerepository.Setup(x => x.GetDeliverablesByDeliverableGroup(It.IsAny <int>())).Returns(deliverablelist); mockbudgetService.Setup(x => x.GetDeliverablesByDeliverableGroup(It.IsAny <int>())).Returns(deliverablelist); #endregion var budgetservice = new BudgetServiceMock(_deliverableRepository: mockdeliverablerepository.Object); var contractservice = new ContractRequestControllerMock(budgetservice: mockbudgetService.Object); var results = budgetservice.GetDeliverablesByDeliverableGroup(MRM_USER_ID); viewModel = ContractRequestMapper.CRDeliverableMapper(deliverablelist); #region Assets Assert.IsNotNull(results); Assert.IsNotNull(viewModel); Assert.IsTrue(results.Count > 0); Assert.AreEqual(viewModel[0].Vendor, SAPVendorName); #endregion }