public void CreateDetails() { for (int i = 0; i < details.Length; i++) { StageDetails stage = new StageDetails(details[i].nameParent, details[i].nameChild, details[i].nameLayer, details[i].map, details[i].sprites, details[i].colors, details[i].offsetX, details[i].offsetY, details[i].order, details[i].scale, details[i].down, details[i].h, details[i].count); } }
protected IStageDetails BuildStageDetails(string contentType, string region, CostType costType, string productionType, bool?isUsage = null) { var result = new StageDetails { Data = new Dictionary <string, dynamic>() }; result.Data.Add("budgetRegion", new AbstractTypeValue { Key = region }); result.Data.Add("contentType", JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827da\",\"value\":\"" + contentType + "\",\"key\":\"" + contentType + "\"}")); if (costType == CostType.Production) { result.Data.Add("productionType", JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827dd\",\"value\":\"" + productionType + "\",\"key\":\"" + productionType + "\"}")); } result.Data.Add("costType", costType); if (isUsage.HasValue) { result.Data.Add("isUsage", isUsage.Value); result.Data.Add("usageBuyoutType", new DictionaryValue { Key = contentType }); } return(result); }
protected IStageDetails BuildStageDetails(Guid revisionId, string contentType, decimal budget, string region, CostType costType, string productionType = null, bool?isUsage = null, CostStages costStage = CostStages.OriginalEstimate) { _costStageRevisionService.Setup(x => x.GetCostLineItems(It.IsAny <Guid>())) .ReturnsAsync(new List <CostLineItemView>() { new CostLineItemView() { ValueInDefaultCurrency = budget } }); var t = new List <CostStageRevision>() { new CostStageRevision() { Id = revisionId, CostStage = new CostStage() { Key = costStage.ToString() } } }; _efContext.MockAsyncQueryable(t.AsQueryable(), x => x.CostStageRevision); var result = new StageDetails() { Data = new Dictionary <string, dynamic>() }; result.Data.Add("initialBudget", budget); result.Data.Add("budgetRegion", new AbstractTypeValue { Key = region }); if (costType == CostType.Production) { result.Data.Add("contentType", JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827da\",\"value\":\"" + contentType + "\",\"key\":\"" + contentType + "\"}")); result.Data.Add("productionType", JObject.Parse("{\"id\":\"b4a1bb22-90ab-4e37-82bd-494e512827dd\",\"value\":\"" + productionType + "\",\"key\":\"" + productionType + "\"}")); } result.Data.Add("costType", costType); if (isUsage.HasValue) { result.Data.Add("isUsage", isUsage.Value); result.Data.Add("usageBuyoutType", new DictionaryValue { Key = contentType }); } return(result); }
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); }
internal static OrderResourceData DeserializeOrderResourceData(JsonElement element) { ResourceIdentifier id = default; string name = default; ResourceType type = default; SystemData systemData = default; Optional <IReadOnlyList <string> > orderItemIds = default; Optional <StageDetails> currentStage = default; Optional <IReadOnlyList <StageDetails> > orderStageHistory = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("id")) { id = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("type")) { type = property.Value.GetString(); continue; } if (property.NameEquals("systemData")) { systemData = JsonSerializer.Deserialize <SystemData>(property.Value.ToString()); continue; } if (property.NameEquals("properties")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("orderItemIds")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(item.GetString()); } orderItemIds = array; continue; } if (property0.NameEquals("currentStage")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } currentStage = StageDetails.DeserializeStageDetails(property0.Value); continue; } if (property0.NameEquals("orderStageHistory")) { if (property0.Value.ValueKind == JsonValueKind.Null) { property0.ThrowNonNullablePropertyIsNull(); continue; } List <StageDetails> array = new List <StageDetails>(); foreach (var item in property0.Value.EnumerateArray()) { array.Add(StageDetails.DeserializeStageDetails(item)); } orderStageHistory = array; continue; } } continue; } } return(new OrderResourceData(id, name, type, systemData, Optional.ToList(orderItemIds), currentStage.Value, Optional.ToList(orderStageHistory))); }
public override void Start(StageExecution execution) { _details.Add(_current = new StageDetails(execution, _vmPauseTimeAccumulator)); }
internal OrderResourceData(ResourceIdentifier id, string name, ResourceType type, SystemData systemData, IReadOnlyList <string> orderItemIds, StageDetails currentStage, IReadOnlyList <StageDetails> orderStageHistory) : base(id, name, type, systemData) { OrderItemIds = orderItemIds; CurrentStage = currentStage; OrderStageHistory = orderStageHistory; }