private void HandleFeatureDependencies(FeatureInfo featureInfo, string sourceElementId) { foreach (FeatureInfo dependency in featureInfo.DependenciesInfo) { this.HandleNode(dependency, sourceElementId); } }
private void HandleNode(FeatureInfo featureInfo, string sourceElementId) { FeatureInfo existingFeatureInfo = this.workedFeatureInfo.SingleOrDefault(x => x.UniqueName == featureInfo.UniqueName); if (existingFeatureInfo != null) { if (!string.IsNullOrEmpty(sourceElementId)) { XElement link = this.elementCreater.GenerateLink(sourceElementId, existingFeatureInfo, featureInfo.FeatureType); this.links.Add(link); this.HandleFeatureDependencies(featureInfo, existingFeatureInfo.Id); } } else { XElement node = this.elementCreater.GenerateNode(featureInfo); this.nodes.Add(node); XElement link = this.elementCreater.GenerateLink(sourceElementId, featureInfo, featureInfo.FeatureType); this.links.Add(link); this.workedFeatureInfo.Add(featureInfo); this.HandleFeatureDependencies(featureInfo, featureInfo.Id); } }
public void OnFeatureStart(FeatureInfo featureInfo) { // No enqueueing // I don't like the idea of enqueueing async steps in a BeforeFeature. Feels like code/test smell // Also, feature setup/teardown is static, so there will be no context testRunner.OnFeatureStart(featureInfo); }
public void OnFeatureStart_DefersToInnerSynchronousTestRunner() { var featureInfo = new FeatureInfo(CultureInfoHelper.GetCultureInfo("en-us"), "title", "description"); asyncTestRunner.OnFeatureStart(featureInfo); testExecutionEngineStub.Verify(m => m.OnFeatureStart(featureInfo)); }
public XElement GenerateNode(FeatureInfo featureInfo) { string color = this.colorSelector.GetBackgroundColor(featureInfo.FeatureType); var node = new XElement( this.nameSpace + "Node", new XAttribute("Id", featureInfo.Id), new XAttribute("Label", featureInfo.Name), new XAttribute("Background", color), new XAttribute("Category", featureInfo.AssemblyName)); return node; }
public StepContext(FeatureInfo featureInfo, ScenarioInfo scenarioInfo) { Language = featureInfo == null ? CultureInfoHelper.GetCultureInfo(ConfigDefaults.FeatureLanguage) : featureInfo.Language; FeatureTitle = featureInfo == null ? null : featureInfo.Title; ScenarioTitle = scenarioInfo == null ? null : scenarioInfo.Title; var tags = Enumerable.Empty<string>(); if (featureInfo != null && featureInfo.Tags != null) tags = tags.Concat(featureInfo.Tags); if (scenarioInfo != null && scenarioInfo.Tags != null) tags = tags.Concat(scenarioInfo.Tags).Distinct(); Tags = tags; }
public XElement GenerateLink(string sourceElementId, FeatureInfo targetElement, FeatureType featureType) { string color = this.colorSelector.GetLinkColor(featureType); XAttribute label = string.IsNullOrEmpty(targetElement.BindingTarget.ToString()) ? new XAttribute("Label", featureType) : new XAttribute("Label", "Binding " + targetElement.BindingTarget); var link = new XElement( this.nameSpace + "Link", new XAttribute("Source", sourceElementId), new XAttribute("Target", targetElement.Id), new XAttribute("Stroke", color), new XAttribute("StrokeDashArray", "3"), label); return link; }
public void OnFeatureStart(FeatureInfo featureInfo) { // if the unit test provider would execute the fixture teardown code // only delayed (at the end of the execution), we automatically close // the current feature if necessary if (unitTestRuntimeProvider.DelayedFixtureTearDown && contextManager.FeatureContext != null) { OnFeatureEnd(); } // The Generator defines the value of FeatureInfo.Language: either feature-language or language from App.config or the default // The runtime can define the binding-culture: Value is configured on App.config, else it is null CultureInfo bindingCulture = runtimeConfiguration.BindingCulture ?? featureInfo.Language; defaultTargetLanguage = featureInfo.GenerationTargetLanguage; defaultBindingCulture = bindingCulture; contextManager.InitializeFeatureContext(featureInfo, bindingCulture); FireEvents(HookType.BeforeFeature); }
public TextDownloader(FeatureInfo feature) : base(feature) { }
public ZipDownloader(FeatureInfo feature) : base(feature) { _affectedFiles = Feature.ZipTargets.Select(t => Path.Combine(t.Location, Path.GetFileName(t.Target))).ToArray(); }
public Setup(FeatureInfo featureInfo, ScenarioInfo scenarioInfo, ScenarioContext scenarioContext) { _featureInfo = featureInfo; _scenarioInfo = scenarioInfo; _scenarioContext = scenarioContext; }
public void Add(FeatureInfo feature) { features.Add(feature); }
public static void BeforeScenario(FeatureInfo featureInfo) { }
public static void BeforeScenario(FeatureInfo featureInfo) { scenario = featureName.CreateNode <Scenario>(ScenarioContext.Current.ScenarioInfo.Title); }
private static Tuple <List <Label>, List <Link> > GetTags(FeatureInfo featureInfo, ScenarioInfo scenarioInfo) { var result = Tuple.Create(new List <Label>(), new List <Link>()); var tags = scenarioInfo.Tags .Union(featureInfo.Tags) .Distinct(StringComparer.CurrentCultureIgnoreCase); foreach (var tag in tags) { // link if (TryUpdateValueByMatch(SpecFlowCfg.links.link, tag, out var tagValue)) { var linkAttr = new AllureLinkAttribute(tagValue); var link = ReportHelper.GetValueWithPattern(linkAttr); result.Item2.Add(link); continue; } // issue if (TryUpdateValueByMatch(SpecFlowCfg.links.issue, tag, out tagValue)) { var issueAttr = new AllureIssueAttribute(tagValue); var issue = ReportHelper.GetValueWithPattern(issueAttr); result.Item2.Add(issue); continue; } // tms if (TryUpdateValueByMatch(SpecFlowCfg.links.tms, tag, out tagValue)) { var tmsAttr = new AllureTmsAttribute(tagValue); var tms = ReportHelper.GetValueWithPattern(tmsAttr); result.Item2.Add(tms); continue; } // parent suite if (TryUpdateValueByMatch(SpecFlowCfg.grouping.suites.parentSuite, tag, out tagValue)) { result.Item1.Add(Label.ParentSuite(tagValue)); continue; } // suite if (TryUpdateValueByMatch(SpecFlowCfg.grouping.suites.suite, tag, out tagValue)) { result.Item1.Add(Label.Suite(tagValue)); continue; } // sub suite if (TryUpdateValueByMatch(SpecFlowCfg.grouping.suites.subSuite, tag, out tagValue)) { result.Item1.Add(Label.SubSuite(tagValue)); continue; } // epic if (TryUpdateValueByMatch(SpecFlowCfg.grouping.behaviors.epic, tag, out tagValue)) { result.Item1.Add(Label.Epic(tagValue)); continue; } // story if (TryUpdateValueByMatch(SpecFlowCfg.grouping.behaviors.story, tag, out tagValue)) { result.Item1.Add(Label.Story(tagValue)); continue; } // package if (TryUpdateValueByMatch(SpecFlowCfg.grouping.packages.package, tag, out tagValue)) { result.Item1.Add(Label.Package(tagValue)); continue; } // test class if (TryUpdateValueByMatch(SpecFlowCfg.grouping.packages.testClass, tag, out tagValue)) { result.Item1.Add(Label.TestClass(tagValue)); continue; } // test method if (TryUpdateValueByMatch(SpecFlowCfg.grouping.packages.testMethod, tag, out tagValue)) { result.Item1.Add(Label.TestMethod(tagValue)); continue; } // owner if (TryUpdateValueByMatch(SpecFlowCfg.labels.owner, tag, out tagValue)) { result.Item1.Add(Label.Owner(tagValue)); continue; } // severity if (TryUpdateValueByMatch(SpecFlowCfg.labels.severity, tag, out tagValue) && Enum.TryParse(tagValue, true, out SeverityLevel level)) { result.Item1.Add(Label.Severity(level)); continue; } result.Item1.Add(Label.Tag(tag)); } return(result); }
//#region 读取excel文件 ///// <summary> ///// 读取excel文件 ///// </summary> ///// <param name="strFilePath"></param> ///// <returns></returns> //private ArrayList ReadExcelFile(string strFilePath) //{ // string text = ""; // object missing = Type.Missing; // ArrayList arrayList = new ArrayList(); // Excel.Application application = new ApplicationClass(); // _Workbook workbook = application.Workbooks._Open(strFilePath, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); // _Worksheet worksheet = (Worksheet)workbook.Sheets.get_Item(1); // for (int i = 2; i <= worksheet.UsedRange.Rows.Count; i++) // { // for (int j = 1; j <= worksheet.UsedRange.Columns.Count; j++) // { // text = text + GetCellText(i, j, worksheet) + "&"; // } // arrayList.Add(text); // text = ""; // } // try // { // if (application != null) // { // if (workbook != null) // { // if (worksheet != null) // { // Marshal.ReleaseComObject(worksheet); // } // workbook.Close(false, false, missing); // Marshal.ReleaseComObject(workbook); // } // application.Quit(); // Marshal.ReleaseComObject(application); // GC.Collect(0); // } // } // catch (Exception ex) // { // throw new Exception(ex.Message); // } // finally // { // Process[] processesByName = Process.GetProcessesByName("Excel"); // for (int k = 0; k < processesByName.Length; k++) // { // Process process = processesByName[k]; // process.Kill(); // } // } // return arrayList; //} //public static string GetCellText(int row, int col, Excel._Worksheet oSheet) //{ // string result = ""; // bool flag = false; // int num = 1; // Range range = (Range)oSheet.Cells.get_Item(row, col); // if (range.Value2 != null) // { // result = range.Value2.ToString(); // flag = true; // } // else // { // if (!(bool)range.MergeCells) // { // result = null; // flag = true; // } // } // if (!flag) // { // for (int i = row - 1; i >= 1; i--) // { // range = (Range)oSheet.Cells.get_Item(i, col); // if (!(bool)range.MergeCells) // { // num = i + 1; // break; // } // try // { // if (range.Value2 != null) // { // result = range.Value2.ToString(); // flag = true; // break; // } // } // catch (Exception) // { // } // } // if (!flag) // { // for (int j = col - 1; j >= 1; j--) // { // range = (Range)oSheet.Cells.get_Item(num, j); // if (!(bool)range.MergeCells) // { // int num2 = j + 1; // break; // } // try // { // if (range.Value2 != null) // { // result = range.Value2.ToString(); // flag = true; // break; // } // } // catch (Exception) // { // } // } // } // if (!flag) // { // result = null; // } // } // if (range != null) // { // Marshal.ReleaseComObject(range); // range = null; // } // return result; //} //#endregion #region 合并同类要素 public void autoMerge(FeatureInfo feaInfo) { int nType = feaInfo.nType; string strGeoNum = feaInfo.strGeoNum; string strFeaClass = feaInfo.strFeaClass; string strMark = feaInfo.strMark + ";" + strGeoNum; string[] array; if (strMark != "") { array = strMark.Split(new char[] { ';' }); } else { array = null; } ArrayList arrayList = new ArrayList(); IQueryFilter queryFilter = new QueryFilterClass(); IFeatureClass featureClass = this.m_pFeaWsp.OpenFeatureClass(strFeaClass); IFeatureCursor featureCursor; IFeature feature, feature2; esriSpatialRelEnum spatialRel; IPolyline polyline; IPolygon polygon; IPointCollection pPtC; ESRI.ArcGIS.Geometry.IPoint pPt0, pPtn; queryFilter.WhereClause = "SMSSYMBOL ='" + strGeoNum + "'"; if (nType == 1 || nType == 2 || nType == 5) { featureCursor = this.m_pFCAssist.Search(queryFilter, true); } else { featureCursor = featureClass.Update(queryFilter, true); } if (featureCursor == null) { return; } feature = featureCursor.NextFeature(); switch (nType) { case 1: { spatialRel = esriSpatialRelEnum.esriSpatialRelContains; while (feature != null) { polyline = (IPolyline)feature.Shape; pPtC = polyline as IPointCollection; pPt0 = pPtC.get_Point(0); pPtn = pPtC.get_Point(pPtC.PointCount - 1); if (polyline.IsClosed || (pPtC.PointCount > 2 && Math.Abs(pPt0.X - pPtn.X) < 0.05 && Math.Abs(pPt0.Y - pPtn.Y) < 0.05)) { polygon = this.polylinetoPolygon(polyline); polygon = (IPolygon)(polygon as ITopologicalOperator).Buffer(0.05); for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polygon, spatialRel, array[i]); } } feature = featureCursor.NextFeature(); } break; } case 2: { spatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; while (feature != null) { polyline = (IPolyline)feature.Shape; for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polyline, spatialRel, array[i]); } feature = featureCursor.NextFeature(); } break; } case 3: { spatialRel = esriSpatialRelEnum.esriSpatialRelContains; while (feature != null) { polyline = (IPolyline)feature.Shape; pPtC = polyline as IPointCollection; pPt0 = pPtC.get_Point(0); pPtn = pPtC.get_Point(pPtC.PointCount - 1); if (polyline.IsClosed || (pPtC.PointCount > 2 && Math.Abs(pPt0.X - pPtn.X) < 0.05 && Math.Abs(pPt0.Y - pPtn.Y) < 0.05)) { polygon = this.polylinetoPolygon(polyline); for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polygon, spatialRel, array[i]); if (feature2 != null) { feature.Shape = CommonFunction.UnionGeometry(feature.Shape, feature2.Shape); feature.Store(); feature2.Delete(); } } } feature = featureCursor.NextFeature(); } break; } case 4: { spatialRel = esriSpatialRelEnum.esriSpatialRelContains; while (feature != null) { polyline = (IPolyline)feature.Shape; pPtC = polyline as IPointCollection; pPt0 = pPtC.get_Point(0); pPtn = pPtC.get_Point(pPtC.PointCount - 1); if (polyline.IsClosed || (pPtC.PointCount > 2 && Math.Abs(pPt0.X - pPtn.X) < 0.05 && Math.Abs(pPt0.Y - pPtn.Y) < 0.05)) { polygon = this.polylinetoPolygon(polyline); for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polygon, spatialRel, array[i]); } } feature = featureCursor.NextFeature(); } break; } case 5: { spatialRel = esriSpatialRelEnum.esriSpatialRelContains; while (feature != null) { polyline = (IPolyline)feature.Shape; polygon = (IPolygon)(polyline as ITopologicalOperator).Buffer(1.01); for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polygon, spatialRel, array[i]); } feature = featureCursor.NextFeature(); } break; } case 6: { spatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; while (feature != null) { if ((feature.Shape as IGeometryCollection).GeometryCount == 1) { polyline = (IPolyline)feature.Shape; polygon = (IPolygon)(polyline as ITopologicalOperator).Buffer(0.05); for (int i = 0; i < array.Length; i++) { feature2 = this.FeatureMerge(featureClass, polygon, spatialRel, array[i]); } } feature = featureCursor.NextFeature(); } break; } } }
public IObjectContainer CreateFeatureContainer(IObjectContainer testThreadContainer, FeatureInfo featureInfo) => _innerContainerBuilder.CreateFeatureContainer(testThreadContainer, featureInfo);
public void OnFeatureStart(FeatureInfo featureInfo) { _TestRunner.OnFeatureStart(featureInfo); }
public void OnFeatureStart(FeatureInfo featureInfo) { throw new NotImplementedException(); }
public StepContext(FeatureInfo featureInfo, ScenarioInfo scenarioInfo) { FeatureInfo = featureInfo; ScenarioInfo = scenarioInfo; }
public async Task <int> SaveCreature([FromBody] CreatureEditInput input) { if (input.IsPlayerCharacter && input.CreatureId == 0) { if (await dbContext.Creatures.CountAsync(c => !c.Delisted && c.IsPlayerCharacter && c.Author.Id == userSession.Player.Id) >= 6) { return(0); //they were warned client-side that the beta only allows six player characters } } Creature creature = null; if (input.CreatureId > 0) { creature = await this.CreatureQuery.Where(c => c.Author.Id == this.userSession.Player.Id) .SingleOrDefaultAsync(c => c.Id == input.CreatureId); } else { creature = new Creature(); creature.CreatedAtMS = System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); dbContext.Entry(creature).State = EntityState.Added; dbContext.Attach(this.userSession.Player); creature.Author = this.userSession.Player; } if (!string.IsNullOrWhiteSpace(input.DescriptionChangedTo)) { creature.Description = input.DescriptionChangedTo; } if (!string.IsNullOrWhiteSpace(input.HairChangedTo)) { creature.Hair = input.HairChangedTo; } if (!string.IsNullOrWhiteSpace(input.AgeChangedTo)) { creature.Age = input.AgeChangedTo; } if (!string.IsNullOrWhiteSpace(input.WeightChangedTo)) { creature.Weight = input.WeightChangedTo; } if (!string.IsNullOrWhiteSpace(input.HeightChangedTo)) { creature.Height = input.HeightChangedTo; } if (!string.IsNullOrWhiteSpace(input.SkinChangedTo)) { creature.Skin = input.SkinChangedTo; } if (!string.IsNullOrWhiteSpace(input.EyesChangedTo)) { creature.Eyes = input.EyesChangedTo; } if (!string.IsNullOrWhiteSpace(input.NameChangedTo)) { creature.Name = input.NameChangedTo; } if (!string.IsNullOrWhiteSpace(input.GenderChangedTo)) { creature.Gender = input.GenderChangedTo; } if (input.RaceIdChangedTo > 0) { creature.Race = await dbContext.Races.SingleOrDefaultAsync(r => r.Id == input.RaceIdChangedTo); } else if (input.RaceIdChangedTo < 0) //-1 means remove Race { creature.Race = null; } creature.CurrentEnergyLedger = input.CurrentEnergyLedgerIs; creature.Level = input.LevelIs; creature.IsPlayerCharacter = input.IsPlayerCharacter; foreach (var oathInfoVM in input.NewOathInformation) { OathInfo oathInfo = new OathInfo { Broken = oathInfoVM.Broken, OathId = oathInfoVM.Oath.OathId, Notes = oathInfoVM.Notes }; creature.OathInformation.Add(oathInfo); } foreach (var featureInfoVM in input.NewFeatureInformation) { FeatureInfo featureInfo = new FeatureInfo { FeatureId = featureInfoVM.Feature.FeatureId, CostWhenTaken = featureInfoVM.CostWhenTaken, EnergySacrificedWhenTaken = featureInfoVM.EnergySacrificedWhenTaken, TakenAtLevel = featureInfoVM.TakenAtLevel, Notes = featureInfoVM.Notes }; if (featureInfoVM.FeatureInfoId > 0) { var existingFeatureInfo = creature.FeatureInformation.FirstOrDefault(fi => fi.Id == featureInfoVM.FeatureInfoId); if (existingFeatureInfo != null) { dbContext.Entry(existingFeatureInfo).State = EntityState.Detached; featureInfo.Id = featureInfoVM.FeatureInfoId; dbContext.Attach(featureInfo); dbContext.Entry(featureInfo).State = EntityState.Modified; } } else { creature.FeatureInformation.Add(featureInfo); } } foreach (var itemInfoVM in input.NewItemInformation) { ItemInfo itemInfo = new ItemInfo { ItemId = itemInfoVM.Item.EquipmentId, Notes = itemInfoVM.Notes }; if (itemInfoVM.ItemInfoId > 0) { // make sure this actually belongs to this here creature var existingItemInfo = creature.ItemInformation.FirstOrDefault(ii => ii.Id == itemInfoVM.ItemInfoId); if (existingItemInfo != null) { dbContext.Entry(existingItemInfo).State = EntityState.Detached; itemInfo.Id = itemInfoVM.ItemInfoId; dbContext.Attach(itemInfo); dbContext.Entry(itemInfo).State = EntityState.Modified; } } else { creature.ItemInformation.Add(itemInfo); } } foreach (var weaponInfoFeatureChange in input.WeaponFeatureChanges) { var weaponInfo = creature.WeaponInformation.FirstOrDefault(si => si.Id == weaponInfoFeatureChange.WeaponInfoId); if (weaponInfo == null) { continue; } foreach (var featureInfoVM in weaponInfoFeatureChange.NewFeatures) { var featureInfo = featureInfoVM.ToDomainModel(); featureInfo.Feature = null; weaponInfo.FeaturesApplied.Add(featureInfo); } weaponInfo.FeaturesApplied.RemoveAll(fi => weaponInfoFeatureChange.DeletedFeatureInfoIds.Contains(fi.Id)); } foreach (var weaponInfoVM in input.NewWeaponInformation) { WeaponInfo weaponInfo = new WeaponInfo { WeaponId = weaponInfoVM.Weapon.EquipmentId, Notes = weaponInfoVM.Notes }; if (weaponInfoVM.WeaponInfoId > 0) { // make sure this actually belongs to this here creature var existingWeaponInfo = creature.ItemInformation.FirstOrDefault(ii => ii.Id == weaponInfoVM.WeaponInfoId); if (existingWeaponInfo != null) { dbContext.Entry(existingWeaponInfo).State = EntityState.Detached; weaponInfo.Id = weaponInfoVM.WeaponInfoId; dbContext.Attach(weaponInfo); dbContext.Entry(weaponInfo).State = EntityState.Modified; } } else { foreach (var featureInfoVM in weaponInfoVM.FeaturesApplied) { var featureInfo = featureInfoVM.ToDomainModel(); featureInfo.Feature = null; weaponInfo.FeaturesApplied.Add(featureInfo); } creature.WeaponInformation.Add(weaponInfo); } } foreach (var armorInfoVM in input.NewArmorInformation) { ArmorInfo armorInfo = new ArmorInfo { ArmorId = armorInfoVM.Armor.EquipmentId, Notes = armorInfoVM.Notes }; if (armorInfoVM.ArmorInfoId > 0) { // make sure this actually belongs to this here creature var existingWeaponInfo = creature.ArmorInformation.FirstOrDefault(ii => ii.Id == armorInfoVM.ArmorInfoId); if (existingWeaponInfo != null) { dbContext.Entry(existingWeaponInfo).State = EntityState.Detached; armorInfo.Id = armorInfoVM.ArmorInfoId; dbContext.Attach(armorInfo); dbContext.Entry(armorInfo).State = EntityState.Modified; } } else { creature.ArmorInformation.Add(armorInfo); } } foreach (var flawInfoVM in input.NewFlawInformation) { FlawInfo flawInfo = new FlawInfo { FlawId = flawInfoVM.Flaw.FlawId, Notes = flawInfoVM.Notes }; if (flawInfoVM.FlawInfoId > 0) { // make sure this actually belongs to this here creature var existingFlawInfo = creature.FlawInformation.FirstOrDefault(fi => fi.Id == flawInfoVM.FlawInfoId); if (existingFlawInfo != null) { dbContext.Entry(existingFlawInfo).State = EntityState.Detached; flawInfo.Id = flawInfoVM.FlawInfoId; dbContext.Attach(flawInfo); dbContext.Entry(flawInfo).State = EntityState.Modified; } } else { creature.FlawInformation.Add(flawInfo); } } foreach (var spellInfoFeatureChange in input.SpellFeatureChanges) { var spellInfo = creature.SpellInformation.FirstOrDefault(si => si.Id == spellInfoFeatureChange.SpellInfoId); if (spellInfo == null) { continue; } foreach (var featureInfoVM in spellInfoFeatureChange.NewFeatures) { var featureInfo = featureInfoVM.ToDomainModel(); featureInfo.Feature = null; spellInfo.FeaturesApplied.Add(featureInfo); } spellInfo.FeaturesApplied.RemoveAll(fi => spellInfoFeatureChange.DeletedFeatureInfoIds.Contains(fi.Id)); } foreach (var spellInfoVM in input.NewSpellInformation) { SpellInfo spellInfo = new SpellInfo { SpellId = spellInfoVM.Spell.SpellId, Notes = spellInfoVM.Notes, FeaturesApplied = new List <FeatureInfo>() }; if (spellInfoVM.SpellInfoId > 0) { var existingSpellInfo = creature.SpellInformation.FirstOrDefault(si => si.Id == spellInfoVM.SpellInfoId); dbContext.Entry(existingSpellInfo).State = EntityState.Detached; spellInfo.Id = existingSpellInfo.Id; dbContext.Attach(spellInfo); dbContext.Entry(spellInfo).State = EntityState.Modified; } else { foreach (var featureInfoVM in spellInfoVM.FeaturesApplied) { var featureInfo = featureInfoVM.ToDomainModel(); featureInfo.Feature = null; spellInfo.FeaturesApplied.Add(featureInfo); } creature.SpellInformation.Add(spellInfo); } } foreach (var statModVM in input.NewStatMods) { var statMod = statModVM.ToDomainModel(); if (statModVM.StatModId > 0) { var existingStatMod = creature.BaseStats.SingleOrDefault(sm => sm.Id == statModVM.StatModId); if (existingStatMod != null) // make sure this stat belongs to this creature { dbContext.Entry(existingStatMod).State = EntityState.Detached; statMod.Id = statModVM.StatModId; dbContext.Attach(statMod); dbContext.Entry(statMod).State = EntityState.Modified; } } else { statMod.Id = 0; creature.BaseStats.Add(statMod); } } foreach (var skillVM in input.NewSkills) { var skill = new Skill { Name = skillVM.Name, Ranks = skillVM.Ranks, BelongsTo = skillVM.BelongsTo, HasDefense = skillVM.HasDefense }; if (skillVM.SkillId > 0) { var existingSkill = creature.Skills.SingleOrDefault(s => s.Id == skillVM.SkillId); if (existingSkill != null) //make sure this skill belongs to this creature { dbContext.Entry(existingSkill).State = EntityState.Detached; skill.Id = skillVM.SkillId; dbContext.Attach(skill); dbContext.Entry(skill).State = EntityState.Modified; } } else { creature.Skills.Add(skill); } } creature.FlawInformation.RemoveAll(fi => input.DeletedFlawInformationIds.Contains(fi.Id)); creature.OathInformation.RemoveAll(oi => input.DeletedOathInformationIds.Contains(oi.Id)); creature.FeatureInformation.RemoveAll(fi => input.DeletedFeatureInformationIds.Contains(fi.Id)); creature.WeaponInformation.RemoveAll(wi => input.DeletedWeaponInformationIds.Contains(wi.Id)); creature.ArmorInformation.RemoveAll(ai => input.DeletedArmorInformationIds.Contains(ai.Id)); creature.ItemInformation.RemoveAll(ii => input.DeletedArmorInformationIds.Contains(ii.Id)); creature.SpellInformation.RemoveAll(si => input.DeletedSpellInfoIds.Contains(si.Id)); creature.Skills.RemoveAll(s => input.DeletedSkillIds.Contains(s.Id)); creature.BaseStats.RemoveAll(sm => input.DeletedStatModIds.Contains(sm.Id)); await dbContext.SaveChangesAsync(); return(creature.Id); }
public bool Equals(FeatureInfo obj) { return(this.Region.Equals((object)obj.Region) && this.FeatureName.Equals(obj.FeatureName)); }
private void AddItem(FeatureInfo feature, C1TreeNodeCollection nodes) { var node = nodes.Add(feature); }
private static Tuple <List <Label>, List <Link> > GetTags(FeatureInfo featureInfo, ScenarioInfo scenarioInfo) { var result = Tuple.Create(new List <Label>(), new List <Link>()); var tags = scenarioInfo.Tags .Union(featureInfo.Tags) .Distinct(StringComparer.CurrentCultureIgnoreCase); foreach (var tag in tags) { var tagValue = tag; // issue if (TryUpdateValueByMatch(config.IssueRegex, ref tagValue)) { result.Item2.Add(Link.Issue(tagValue)); continue; } // tms if (TryUpdateValueByMatch(config.TmsRegex, ref tagValue)) { result.Item2.Add(Link.Tms(tagValue)); continue; } // parent suite if (TryUpdateValueByMatch(config.ParentSuiteRegex, ref tagValue)) { result.Item1.Add(Label.ParentSuite(tagValue)); continue; } // suite if (TryUpdateValueByMatch(config.SuiteRegex, ref tagValue)) { result.Item1.Add(Label.Suite(tagValue)); continue; } // sub suite if (TryUpdateValueByMatch(config.SubSuiteRegex, ref tagValue)) { result.Item1.Add(Label.SubSuite(tagValue)); continue; } // epic if (TryUpdateValueByMatch(config.EpicRegex, ref tagValue)) { result.Item1.Add(Label.Epic(tagValue)); continue; } // story if (TryUpdateValueByMatch(config.StoryRegex, ref tagValue)) { result.Item1.Add(Label.Story(tagValue)); continue; } // package if (TryUpdateValueByMatch(config.PackageRegex, ref tagValue)) { result.Item1.Add(Label.Package(tagValue)); continue; } // test class if (TryUpdateValueByMatch(config.TestClassRegex, ref tagValue)) { result.Item1.Add(Label.TestClass(tagValue)); continue; } // test method if (TryUpdateValueByMatch(config.TestMethodRegex, ref tagValue)) { result.Item1.Add(Label.TestMethod(tagValue)); continue; } // owner if (TryUpdateValueByMatch(config.OwnerRegex, ref tagValue)) { result.Item1.Add(Label.Owner(tagValue)); continue; } // severity if (TryUpdateValueByMatch(config.SeverityRegex, ref tagValue) && Enum.TryParse(tagValue, out SeverityLevel level)) { result.Item1.Add(Label.Severity(level)); continue; } // tag result.Item1.Add(Label.Tag(tagValue)); } return(result); }
public ITestDataProvider GetTestDataProvider(FeatureInfo fi, ScenarioInfo si, FeatureContext fc, ScenarioContext sc) { return(new GhprMSTestSpecFlowTestDataProvider(sc.TryGetTestContext(), sc, fc)); }
public TestExecutionEngineTests() { specFlowConfiguration = ConfigurationLoader.GetDefault(); testThreadContainer = new ObjectContainer(); featureContainer = new ObjectContainer(); scenarioContainer = new ObjectContainer(); beforeScenarioEvents = new List <IHookBinding>(); afterScenarioEvents = new List <IHookBinding>(); beforeStepEvents = new List <IHookBinding>(); afterStepEvents = new List <IHookBinding>(); beforeFeatureEvents = new List <IHookBinding>(); afterFeatureEvents = new List <IHookBinding>(); beforeTestRunEvents = new List <IHookBinding>(); afterTestRunEvents = new List <IHookBinding>(); beforeScenarioBlockEvents = new List <IHookBinding>(); afterScenarioBlockEvents = new List <IHookBinding>(); stepDefinitionSkeletonProviderMock = new Mock <IStepDefinitionSkeletonProvider>(); testObjectResolverMock = new Mock <ITestObjectResolver>(); testObjectResolverMock.Setup(bir => bir.ResolveBindingInstance(It.IsAny <Type>(), It.IsAny <IObjectContainer>())) .Returns((Type t, IObjectContainer container) => defaultTestObjectResolver.ResolveBindingInstance(t, container)); var culture = new CultureInfo("en-US"); contextManagerStub = new Mock <IContextManager>(); scenarioInfo = new ScenarioInfo("scenario_title", "scenario_description"); scenarioContext = new ScenarioContext(scenarioContainer, scenarioInfo, testObjectResolverMock.Object); scenarioContainer.RegisterInstanceAs(scenarioContext); contextManagerStub.Setup(cm => cm.ScenarioContext).Returns(scenarioContext); featureInfo = new FeatureInfo(culture, "feature_title", "", ProgrammingLanguage.CSharp); var featureContext = new FeatureContext(featureContainer, featureInfo, specFlowConfiguration); featureContainer.RegisterInstanceAs(featureContext); contextManagerStub.Setup(cm => cm.FeatureContext).Returns(featureContext); contextManagerStub.Setup(cm => cm.StepContext).Returns(new ScenarioStepContext(new StepInfo(StepDefinitionType.Given, "step_title", null, null))); bindingRegistryStub = new Mock <IBindingRegistry>(); bindingRegistryStub.Setup(br => br.GetHooks(HookType.BeforeStep)).Returns(beforeStepEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.AfterStep)).Returns(afterStepEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.BeforeScenarioBlock)).Returns(beforeScenarioBlockEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.AfterScenarioBlock)).Returns(afterScenarioBlockEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.BeforeFeature)).Returns(beforeFeatureEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.AfterFeature)).Returns(afterFeatureEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.BeforeTestRun)).Returns(beforeTestRunEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.AfterTestRun)).Returns(afterTestRunEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.BeforeScenario)).Returns(beforeScenarioEvents); bindingRegistryStub.Setup(br => br.GetHooks(HookType.AfterScenario)).Returns(afterScenarioEvents); specFlowConfiguration = ConfigurationLoader.GetDefault(); errorProviderStub = new Mock <IErrorProvider>(); testTracerStub = new Mock <ITestTracer>(); stepDefinitionMatcherStub = new Mock <IStepDefinitionMatchService>(); methodBindingInvokerMock = new Mock <IBindingInvoker>(); stepErrorHandlers = new Dictionary <string, IStepErrorHandler>(); obsoleteTestHandlerMock = new Mock <IObsoleteStepHandler>(); cucumberMessageSenderMock = new Mock <ICucumberMessageSender>(); cucumberMessageSenderMock.Setup(m => m.SendTestRunStarted()) .Callback(() => { }); _testPendingMessageFactory = new TestPendingMessageFactory(errorProviderStub.Object); _testUndefinedMessageFactory = new TestUndefinedMessageFactory(stepDefinitionSkeletonProviderMock.Object, errorProviderStub.Object, specFlowConfiguration); }
public static void BeforeFeature(FeatureInfo featureInfo) { string typeBrowser = featureInfo.Title.Contains("-") ? featureInfo.Title.Split('-')[0] : null; ClassDriver.GetInstance().StartDriver(typeBrowser); }
private static Tuple <List <Label>, List <Link> > GetTags(FeatureInfo featureInfo, ScenarioInfo scenarioInfo) { var result = Tuple.Create(new List <Label>(), new List <Link>()); var tags = scenarioInfo.Tags .Union(featureInfo.Tags) .Distinct(StringComparer.CurrentCultureIgnoreCase); foreach (var tag in tags) { var tagValue = tag; // link if (TryUpdateValueByMatch(PluginConfiguration.links.link, ref tagValue)) { result.Item2.Add(new Link() { name = tagValue, url = tagValue }); continue; } // issue if (TryUpdateValueByMatch(PluginConfiguration.links.issue, ref tagValue)) { result.Item2.Add(Link.Issue(tagValue, tagValue)); continue; } // tms if (TryUpdateValueByMatch(PluginConfiguration.links.tms, ref tagValue)) { result.Item2.Add(Link.Tms(tagValue, tagValue)); continue; } // parent suite if (TryUpdateValueByMatch(PluginConfiguration.grouping.suites.parentSuite, ref tagValue)) { result.Item1.Add(Label.ParentSuite(tagValue)); continue; } // suite if (TryUpdateValueByMatch(PluginConfiguration.grouping.suites.suite, ref tagValue)) { result.Item1.Add(Label.Suite(tagValue)); continue; } // sub suite if (TryUpdateValueByMatch(PluginConfiguration.grouping.suites.subSuite, ref tagValue)) { result.Item1.Add(Label.SubSuite(tagValue)); continue; } // epic if (TryUpdateValueByMatch(PluginConfiguration.grouping.behaviors.epic, ref tagValue)) { result.Item1.Add(Label.Epic(tagValue)); continue; } // story if (TryUpdateValueByMatch(PluginConfiguration.grouping.behaviors.story, ref tagValue)) { result.Item1.Add(Label.Story(tagValue)); continue; } // package if (TryUpdateValueByMatch(PluginConfiguration.grouping.packages.package, ref tagValue)) { result.Item1.Add(Label.Package(tagValue)); continue; } // test class if (TryUpdateValueByMatch(PluginConfiguration.grouping.packages.testClass, ref tagValue)) { result.Item1.Add(Label.TestClass(tagValue)); continue; } // test method if (TryUpdateValueByMatch(PluginConfiguration.grouping.packages.testMethod, ref tagValue)) { result.Item1.Add(Label.TestMethod(tagValue)); continue; } // owner if (TryUpdateValueByMatch(PluginConfiguration.labels.owner, ref tagValue)) { result.Item1.Add(Label.Owner(tagValue)); continue; } // severity if (TryUpdateValueByMatch(PluginConfiguration.labels.severity, ref tagValue) && Enum.TryParse(tagValue, out SeverityLevel level)) { result.Item1.Add(Label.Severity(level)); continue; } // tag result.Item1.Add(Label.Tag(tagValue)); } return(result); }
private static bool IsGLVersionInfo(FeatureInfo info) { // Null feature name means this feature is the open gl es version feature. return info.Name == null; }
public void Add(FeatureInfo feature) { this.features.Add(feature); }
public IObjectContainer CreateFeatureContainer(IObjectContainer testThreadContainer, FeatureInfo featureInfo) { if (testThreadContainer == null) { throw new ArgumentNullException(nameof(testThreadContainer)); } var featureContainer = new ObjectContainer(testThreadContainer); featureContainer.RegisterInstanceAs(featureInfo); // this registration is needed, otherwise the nested scenario container will create another instance // is this a BoDi bug? featureContainer.RegisterTypeAs <FeatureContext, FeatureContext>(); return(featureContainer); }
public async Task <AuthorizationResult> Evaluate <TRequest>(TRequest request, FeatureInfo feature) { if (feature.IsIn("Admin")) { if (_userSession.IsAnonymous || (await _userSession.User())?.IsAdmin == false) { return(AuthorizationResult.Fail("Unauthorized access")); } } if (feature.Implements <IMustBeAuthenticated>() && _userSession.IsAnonymous) { return(AuthorizationResult.Fail("Authentication is required")); } return(AuthorizationResult.Succeed()); }
bool ActivateFeature(FeatureInfo featureInfo, List<FeatureInfo> featuresToActivate, IConfigureComponents container, PipelineSettings pipelineSettings) { if (featureInfo.Feature.IsActive) { return true; } Func<List<string>, bool> dependencyActivator = dependencies => { var dependantFeaturesToActivate = new List<FeatureInfo>(); foreach (var dependency in dependencies.Select(dependencyName => featuresToActivate .SingleOrDefault(f => f.Feature.Name == dependencyName)) .Where(dependency => dependency != null)) { dependantFeaturesToActivate.Add(dependency); } return dependantFeaturesToActivate.Aggregate(false, (current, f) => current | ActivateFeature(f, featuresToActivate, container, pipelineSettings)); }; var featureType = featureInfo.Feature.GetType(); if (featureInfo.Feature.Dependencies.All(dependencyActivator)) { featureInfo.Diagnostics.DependenciesAreMet = true; var context = new FeatureConfigurationContext(settings, container, pipelineSettings); if (!HasAllPrerequisitesSatisfied(featureInfo.Feature, featureInfo.Diagnostics, context)) { settings.MarkFeatureAsDeactivated(featureType); return false; } settings.MarkFeatureAsActive(featureType); featureInfo.Feature.SetupFeature(context); featureInfo.TaskControllers = context.TaskControllers; featureInfo.Diagnostics.StartupTasks = context.TaskControllers.Select(d => d.Name).ToList(); featureInfo.Diagnostics.Active = true; return true; } settings.MarkFeatureAsDeactivated(featureType); featureInfo.Diagnostics.DependenciesAreMet = false; return false; }
public BinaryDownloader(FeatureInfo feature) : base(feature) { }
public void AddDependency(FeatureInfo dependency) { this.dependenciesInfo.Add(dependency); }
/// <summary> /// Initializes a new instance of the <see cref="FeatureTuple"/> class /// for a pair of features. /// </summary> /// <param name="feature1">First feature.</param> /// <param name="feature2">Second feature.</param> public FeatureTuple(FeatureInfo feature1, FeatureInfo feature2) { this.features = new FeatureInfo[] { feature1, feature2 }; }
public static String CreateFeatureTooltip(FeatureInfo feature) { return(feature.Status.GetDescription().ToUpper()); }
protected FeatureDownloadHandler(FeatureInfo feature) { Feature = feature; }
/// <summary> /// Initializes a new instance of the <see cref="FeatureTuple"/> class /// for a single feature. /// </summary> /// <param name="feature1">Single feature.</param> public FeatureTuple(FeatureInfo feature1) { this.features = new FeatureInfo[] { feature1 }; }
public void OnFeatureStart(FeatureInfo featureInfo) { _runner.OnFeatureStart(featureInfo); _currentFeatureInfo = featureInfo; }
/// <summary> /// Initializes a new instance of FeatureTuple class for a single feature. /// </summary> /// <param name="feature1">Single feature.</param> public FeatureTuple(FeatureInfo feature1) { _features = new FeatureInfo[] { feature1 }; }
/// <summary> /// Initializes a new instance of FeatureTuple class for a pair of features. /// </summary> /// <param name="feature1">First feature.</param> /// <param name="feature2">Second feature.</param> public FeatureTuple(FeatureInfo feature1, FeatureInfo feature2) { _features = new FeatureInfo[] { feature1, feature2 }; }
public void OnFeatureStart(FeatureInfo featureInfo) { // if the unit test provider would execute the fixture teardown code // only delayed (at the end of the execution), we automatically close // the current feature if necessary if (unitTestRuntimeProvider.DelayedFixtureTearDown && contextManager.FeatureContext != null) { OnFeatureEnd(); } if (!stepDefinitionSkeletonProviders.ContainsKey(featureInfo.GenerationTargetLanguage)) currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[ProgrammingLanguage.CSharp]; // fallback case for unsupported skeleton provider currentStepDefinitionSkeletonProvider = stepDefinitionSkeletonProviders[featureInfo.GenerationTargetLanguage]; // The Generator defines the value of FeatureInfo.Language: either feature-language or language from App.config or the default // The runtime can define the binding-culture: Value is configured on App.config, else it is null CultureInfo bindingCulture = runtimeConfiguration.BindingCulture ?? featureInfo.Language; contextManager.InitializeFeatureContext(featureInfo, bindingCulture); FireEvents(BindingEvent.FeatureStart); }
public LearnerMatchApi(TestContext testContext, FeatureInfo featureInfo) { _testContext = testContext; _featureInfo = featureInfo; }