Ejemplo n.º 1
0
        public async Task SupportingDocumentRule_AIPE_Usage()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.PostProductionOnly, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Buyout, new[] { CostStages.Aipe.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(Array.Empty <string>());
        }
Ejemplo n.º 2
0
        public async Task SupportingDocumentRule_FA_on_FirstStage_Usage()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.PostProductionOnly, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Buyout, new[] { CostStages.FinalActual.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Signed contract or letter of extension", "Brief/Call for work" });
        }
Ejemplo n.º 3
0
        public async Task SupportingDocumentRule_AIPE_PostProduction()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.PostProductionOnly, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Production, new[] { CostStages.Aipe.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Supplier winning bid (budget form)", "P&G Communication Brief" });
        }
Ejemplo n.º 4
0
        public async Task SupportingDocumentRule_FA_PostProduction()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.PostProductionOnly, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Production, new[] { CostStages.FinalActual.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Final (online) version approval from brand" });
        }
Ejemplo n.º 5
0
        public async Task SupportingDocumentRule_FP_PostProduction_Image()
        {
            var stageDetails = BuildStageDetails(ContentType.Photography, BudgetRegion.AsiaPacific, CostType.Production, ProductionType.PostProductionOnly, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, CostType.Production, new[] { CostStages.FirstPresentation.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "First Presentation Confirmation Email" });
        }
Ejemplo n.º 6
0
        public async Task SupportingDocumentRule_OE_Usage_Except_NorthAmerica()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Buyout, ProductionType.FullProduction, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Buyout, new[] { CostStages.OriginalEstimate.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Brief/Call for work" });
        }
Ejemplo n.º 7
0
        public async Task SupportingDocumentRule_OE_Production_NorthAmerica_Audio()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.NorthAmerica, dataAccess.Entity.CostType.Production, ProductionType.FullProduction, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Production, new[] { CostStages.OriginalEstimate.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Approved Creative (storyboard/layout/script)", "P&G Communication Brief", "Supplier winning bid (budget form)" });
        }
Ejemplo n.º 8
0
        public async Task SupportingDocumentRule_OE_FullProduction_Except_NorthAmerica_Still()
        {
            var stageDetails = BuildStageDetails(ContentType.Photography, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.FullProduction, false);

            var docs = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Production, new[] { CostStages.OriginalEstimate.ToString() }, Guid.Empty);

            docs.Select(s => s.Name).ToArray().ShouldBeEquivalentTo(new[] { "Supplier winning bid (budget form)", "P&G Communication Brief" });
        }
Ejemplo n.º 9
0
        public async Task SupportingDocumentRule_FP_Revision_Usage()
        {
            var stageDetails = BuildStageDetails(ContentType.Audio, BudgetRegion.AsiaPacific, dataAccess.Entity.CostType.Production, ProductionType.PostProductionOnly, false);
            var docs         = await CostBuilder.BuildSupportingDocuments(stageDetails, dataAccess.Entity.CostType.Buyout, new String[] { CostStages.FirstPresentationRevision.ToString() }, Guid.Empty);

            var docsArray = docs.Select(s => s.Name).ToArray();

            docsArray.ShouldBeEquivalentTo <string[]>(new string[] { "Scope change approval form" });
        }
        public async Task CreateCost_whenCyclonAgencyAnd_shouldSetIsExternalPurchaseEnabledToFalse(bool isCycloneAgency, string budgetRegion, bool isExternalPurchasesEnabled)
        {
            // Arrange
            var userId               = Guid.NewGuid();
            var agencyId             = Guid.NewGuid();
            var agencyAbstractTypeId = Guid.NewGuid();
            var projectId            = "Gdam Porject Id";
            var agency               = new Agency
            {
                Id     = agencyId,
                Name   = "Name",
                Labels = isCycloneAgency ? new[]
                {
                    Constants.Agency.CycloneLabel, Constants.Agency.PAndGLabel, $"{core.Constants.BusinessUnit.CostModulePrimaryLabelPrefix}P&G"
                } :
                new[]
                {
                    Constants.Agency.PAndGLabel, $"{core.Constants.BusinessUnit.CostModulePrimaryLabelPrefix}P&G"
                },
                AbstractTypes = new List <AbstractType>
                {
                    new AbstractType
                    {
                        Id       = Guid.NewGuid(),
                        ObjectId = agencyId,
                    }
                }
            };

            agency.AbstractTypes.First().Agency = agency;
            var costUser = new CostUser
            {
                Id     = userId,
                Agency = agency
            };
            var abstractTypeAgency = new AbstractType
            {
                Id       = agencyAbstractTypeId,
                Agency   = agency,
                ObjectId = agencyId,
                Parent   = new AbstractType
                {
                    Agency = agency
                }
            };

            EFContext.AbstractType.Add(abstractTypeAgency);
            EFContext.CostUser.Add(costUser);
            EFContext.SaveChanges();

            var costTemplateVersion = new CostTemplateVersion
            {
                Id           = Guid.NewGuid(),
                CostTemplate = new CostTemplate
                {
                    Id       = Guid.NewGuid(),
                    CostType = CostType.Production
                }
            };

            CostTemplateVersionServiceMock.Setup(ctv => ctv.GetLatestTemplateVersion(It.Is <Guid>(id => id == costTemplateVersion.CostTemplate.Id)))
            .ReturnsAsync(costTemplateVersion);

            var stageDetailsForm = new PgStageDetailsForm
            {
                ProjectId    = projectId,
                BudgetRegion = new AbstractTypeValue
                {
                    Key = budgetRegion
                },
                Agency = new PgStageDetailsForm.AbstractTypeAgency
                {
                    Id             = abstractTypeAgency.ObjectId,
                    AbstractTypeId = abstractTypeAgency.Id,
                }
            };

            ProjectServiceMock.Setup(p => p.GetByGadmid(projectId)).ReturnsAsync(new Project
            {
                GdamProjectId = projectId,
                AgencyId      = agencyId
            });
            var stageDetails = new StageDetails
            {
                Data = JsonConvert.DeserializeObject <Dictionary <string, dynamic> >(JsonConvert.SerializeObject(stageDetailsForm))
            };

            var createCostModel = new CreateCostModel
            {
                TemplateId   = costTemplateVersion.CostTemplate.Id,
                StageDetails = stageDetails
            };

            PgStageBuilderMock.Setup(sb => sb.GetStages(It.IsAny <PgStageRule>(), null))
            .ReturnsAsync(new Dictionary <string, StageModel>
            {
                {
                    CostStages.New.ToString(),
                    new StageModel
                    {
                        Key         = CostStages.New.ToString(),
                        Transitions = new Dictionary <string, StageModel> {
                            { CostStages.OriginalEstimate.ToString(), new StageModel() }
                        }
                    }
                },
                {
                    CostStages.OriginalEstimate.ToString(),
                    new StageModel {
                        Key = CostStages.OriginalEstimate.ToString()
                    }
                }
            });
            RuleServiceMock.Setup(r => r.GetCompiledByRuleType <SupportingDocumentRule>(RuleType.SupportingDocument)).ReturnsAsync(new List <CompiledRule <SupportingDocumentRule> >());

            // Act
            var result = await CostBuilder.CreateCost(costUser, createCostModel);

            // Assert
            result.Cost.IsExternalPurchasesEnabled.Should().Be(isExternalPurchasesEnabled);
        }