public void CorrectlyGeneratesEnemyTeams_FromRandomizedConfiguration([Values(new [] { FighterType.Goblin, FighterType.Fairy }, new [] { FighterType.Warrior, FighterType.ShieldGuy })] IEnumerable <FighterType> enemyTypes) { List <FighterType> enemyTypesList = enemyTypes.ToList(); TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Barbarian, 5), new EnemyConfiguration(FighterType.ShieldGuy, 2), new EnemyConfiguration(FighterType.ShieldGuy, 3)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new[] { new ChanceEvent <int>(2, 1) }, enemyTypesList, new BattlefieldConfiguration(bossConfiguration)); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _chanceService.PushWhichEventsOccur(0, 0, 1); //first roll determines there will be 2 enemies, then the next 2 specify 1 of each type _regionManager.Battle(_battleManager, _humanTeam); Team enemyTeam = _battleManager.GetAllEnemyTeams()[0]; Assert.IsTrue(enemyTypesList[0].IsCorrectType(enemyTeam.Fighters[0])); Assert.IsTrue(enemyTypesList[1].IsCorrectType(enemyTeam.Fighters[1])); }
public void GetTeamByConfiguration_ReturnsAppropriateTeam([Values(FighterType.Fairy, FighterType.Goblin, FighterType.Warrior)] FighterType firstFighterType, [Range(1, 3)] int numberFirstFighters, [Values(1, 2)] int enemyLevel, [Values(FighterType.Ogre, FighterType.Golem)] FighterType secondFighterType) { List <EnemyConfiguration> enemyConfigurations = new List <EnemyConfiguration>(); int i; for (i = 0; i < numberFirstFighters; ++i) { enemyConfigurations.Add(new EnemyConfiguration(firstFighterType, enemyLevel)); } enemyConfigurations.Add(new EnemyConfiguration(secondFighterType, enemyLevel)); TeamConfiguration configuration = new TeamConfiguration(enemyConfigurations.ToArray()); Team returnedTeam = _teamFactory.GetTeam(configuration); Assert.AreEqual(numberFirstFighters + 1, returnedTeam.Fighters.Count); Assert.IsTrue(returnedTeam.Fighters.TrueForAll(f => f.Level == enemyLevel)); for (i = 0; i < numberFirstFighters; ++i) { Assert.IsTrue(firstFighterType.IsCorrectType(returnedTeam.Fighters[i])); } Assert.IsTrue(secondFighterType.IsCorrectType(returnedTeam.Fighters[i])); }
public void PrintsDefaultIntroString_UponEnteringRegion_NullOrEmptyIntroSuppliedToSubRegion([Values("", null)] string introMessage) { TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new[] { new ChanceEvent <int>(1, 1) }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration), regionIntro: introMessage); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _teamFactory.PushTeams(_oneEnemyTeam); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _regionManager.Battle(_battleManager, _humanTeam); MockOutputMessage[] outputs = _output.GetOutputs(); MockOutputMessage output = outputs[0]; Assert.AreEqual($"You have entered the {WorldRegion.Fields} region\n", output.Message); output = outputs[1]; Assert.AreEqual($"You have entered the {WorldSubRegion.Fields} sub region\n", output.Message); }
public void CorrectlyPrintsIntro_UponEnteringRegion( [Values("Welcome to the Jungle!", "flee, for you have entered the graveyard!")] string regionIntroMessage, [Values("Welcome to a smaller subset of the jungle", "Spooky ghosts watch your every step")] string subRegionIntroMessage) { TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new [] { new ChanceEvent <int>(1, 1) }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration, null), regionIntro: subRegionIntroMessage); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions, regionIntroMessage); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _teamFactory.PushTeams(_oneEnemyTeam); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _regionManager.Battle(_battleManager, _humanTeam); MockOutputMessage[] outputs = _output.GetOutputs(); MockOutputMessage output = outputs[0]; Assert.AreEqual(regionIntroMessage + "\n", output.Message); output = outputs[1]; Assert.AreEqual(subRegionIntroMessage + "\n", output.Message); }
/// <summary> /// Create TFS Team if not exists /// </summary> /// <returns></returns> public TeamFoundationTeam CreateTeam() { // Check team already exists var teams = _tfsTeamService.QueryTeams(_projectInfo.Uri.ToString()); var existingTeam = teams.FirstOrDefault(t => t.Name == _softwareProjectName); if (existingTeam != null) { Console.WriteLine($"Team '{existingTeam.Name}' already exists."); return(existingTeam); } //Create TFS Team TeamFoundationTeam team = _tfsTeamService.CreateTeam( _projectInfo.Uri.ToString(), _softwareProjectName, _softwareProjectDescription, null); //Set the IterationPaths and BacklogIterationPath for the TFS Team var teamConfiguration = _teamSettingsConfigurationService.GetTeamConfigurations(new[] { team.Identity.TeamFoundationId }); TeamConfiguration tconfig = teamConfiguration.FirstOrDefault(); TeamSettings ts = tconfig.TeamSettings; ts.IterationPaths = new string[] { $"{_projectInfo.Name}\\{_softwareProjectName}\\Sprint 1" }; ts.BacklogIterationPath = $"{_projectInfo.Name}\\{_softwareProjectName}"; TeamFieldValue tfv = new TeamFieldValue(); tfv.IncludeChildren = true; tfv.Value = ts.BacklogIterationPath; ts.TeamFieldValues = new TeamFieldValue[] { tfv }; _teamSettingsConfigurationService.SetTeamSettings(tconfig.TeamId, ts); Console.WriteLine($"Team '{team.Name}' created."); return(team); }
public void CorrectlySetsBattleMoves_UponEnteringRegion() { BattleMove superAttack = new AttackBattleMove("foo", TargetType.SingleEnemy, 80, 20, 5); BattleMove fastAttack = new AttackBattleMove("bar", TargetType.SingleEnemy, 100, 0, 0, 2); Assert.False(_humanFighter1.AllSpecialMoves.Contains(superAttack)); Assert.False(_humanFighter1.AllSpecialMoves.Contains(fastAttack)); TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new [] { new ChanceEvent <int>(1, 1), }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration, null)); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new[] { superAttack, fastAttack }, subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _teamFactory.PushTeams(_oneEnemyTeam); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _regionManager.Battle(_battleManager, _humanTeam); Assert.True(_humanFighter1.AllSpecialMoves.Contains(superAttack)); Assert.True(_humanFighter1.AllSpecialMoves.Contains(fastAttack)); }
public void CorrectlyGeneratesEnemyTeams_FromBattlefieldConfiguration([Values(new[] { FighterType.Goblin, FighterType.Fairy }, new[] { FighterType.Warrior, FighterType.ShieldGuy })] IEnumerable <FighterType> enemyTypes) { List <FighterType> enemyTypesList = enemyTypes.ToList(); TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Barbarian, 5), new EnemyConfiguration(FighterType.ShieldGuy, 2), new EnemyConfiguration(FighterType.ShieldGuy, 3)); ShadeGroupingConfiguration shadeGroupingConfig = new ShadeGroupingConfiguration(3, 1); BellType[] bellTypes = { BellType.Silver, BellType.Copper }; BellTerrainConfiguration bellConfig = new BellTerrainConfiguration(bellTypes); BattlefieldConfiguration battleConfig = new BattlefieldConfiguration(shadeGroupingConfig, bellConfig); List <ScriptedBattlefieldConfiguration> scriptedBattlefieldConfigurations = new List <ScriptedBattlefieldConfiguration> { new ScriptedBattlefieldConfiguration(battleConfig, 0) }; SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, 1, new[] { new ChanceEvent <int>(2, 1) }, enemyTypesList, new BattlefieldConfiguration(bossConfiguration), scriptedBattlefieldConfigurations); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); _regionManager = GetRegionManager(); _humanFighter1.SetMove(_runawayMove); _humanFighter1.SetMoveTarget(_humanFighter1); _humanFighter2.SetMove(_doNothingMove); _regionManager.Battle(_battleManager, _humanTeam); Team enemyTeam = _battleManager.GetAllEnemyTeams()[0]; List <IFighter> enemyFighters = enemyTeam.Fighters; Assert.AreEqual(3, enemyFighters.Count); Assert.True(enemyFighters.TrueForAll(ef => ef is Shade)); List <TerrainInteractable> terrainInteractables = _battleManager.GetAllTerrainInteractableLists()[0]; Assert.NotNull(terrainInteractables); Assert.AreEqual(2, terrainInteractables.Count); List <Bell> bells = terrainInteractables.OfType <Bell>().ToList(); Assert.AreEqual(bellTypes.Length, bells.Count); for (var i = 0; i < bellTypes.Length; ++i) { Assert.AreEqual(bellTypes[i], bells[i].BellType); } }
protected override void Seed(Slackish.Data.SlackishContext context) { TenantConfiguration.Seed(context); TeamConfiguration.Seed(context); ChannelConfiguration.Seed(context); UserConfiguration.Seed(context); ProfileConfiguration.Seed(context); }
public void CorrectlyExecutesCutscene_SubRegionCompleted() { const MagicType firstBossEggType = MagicType.Fire; const MagicType secondBossEggType = MagicType.Ice; ColorString[] firstSceneLines = { new ColorString("foo"), new ColorString("bar") }; SingleScene firstSingleScene = new SingleScene(firstSceneLines); ColorString[] secondSceneLines = { new ColorString("baz"), new ColorString("fwee") }; SingleScene secondSingleScene = new SingleScene(secondSceneLines); SingleScene[] scenes = { firstSingleScene, secondSingleScene }; Cutscene regionACutscene = new Cutscene(scenes); TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType)); SubRegion subRegionA = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration), regionCompletedCutscene: regionACutscene); TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType)); SubRegion subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration)); SubRegion[] subRegions = { subRegionA, subRegionB }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion)); AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB)); _mapManager.SetRegionalMap(regionMap); _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap); _regionManager = GetRegionManager(); TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); target.SetHealth(1, 0); _humanFighter1.SetMove(_basicAttackMove, 1); _humanFighter1.SetMove(_runawayMove, 1); _humanFighter1.SetMoveTarget(target); _humanFighter2.SetMove(_doNothingMove); _chanceService.PushAttackHitsNotCrit(); _regionManager.Battle(_battleManager, _humanTeam); List <MockOutputMessage> outputs = _output.GetOutputs().ToList(); List <ColorString> allCutsceneLines = firstSceneLines.Concat(secondSceneLines).ToList(); foreach (ColorString cutsceneLine in allCutsceneLines) { Assert.NotNull(outputs.FirstOrDefault(output => output.Message == cutsceneLine.Value + "\n" && output.Color == cutsceneLine.Color)); } }
public void CorrectlyMovesToNextSubRegion_OnlyOneNextSubRegion() { const MagicType firstBossEggType = MagicType.Fire; const MagicType secondBossEggType = MagicType.Ice; TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType)); SubRegion subRegionA = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration)); const string secondRegionIntro = "Who wants donuts?!?"; TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType)); SubRegion subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration), regionIntro: secondRegionIntro); SubRegion[] subRegions = { subRegionA, subRegionB }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion)); AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB)); _mapManager.SetRegionalMap(regionMap); _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap); _regionManager = GetRegionManager(); TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); target.SetHealth(1, 0); _humanFighter1.SetMove(_basicAttackMove, 1); _humanFighter1.SetMove(_runawayMove, 1); _humanFighter1.SetMoveTarget(target); _humanFighter2.SetMove(_doNothingMove); _chanceService.PushAttackHitsNotCrit(); _regionManager.Battle(_battleManager, _humanTeam); MockOutputMessage[] outputs = _output.GetOutputs(); Assert.NotNull(outputs.FirstOrDefault(o => o.Message == secondRegionIntro + "\n")); List <Team> enemyTeams = _battleManager.GetAllEnemyTeams(); Assert.AreEqual(2, enemyTeams.Count); Egg secondBoss = enemyTeams[1].Fighters[0] as Egg; Assert.NotNull(secondBoss); Assert.AreEqual(secondBossEggType, secondBoss.MagicType); Assert.AreEqual(WorldSubRegion.DesertCrypt, subRegionMap.CurrentArea.AreaId); }
private TeamModel Map(TeamConfiguration teamConfiguration) { return(new TeamModel { Id = teamConfiguration.TeamId, Name = teamConfiguration.TeamName, CurrentIterationPath = teamConfiguration.TeamSettings.CurrentIterationPath, IterationPaths = teamConfiguration.TeamSettings.IterationPaths }); }
public void CorrectlyGeneratesEmptyListOfTerrainInteractables_FromNullInput() { TeamConfiguration teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.Goblin, 1), new EnemyConfiguration(FighterType.Fairy, 1)); BattlefieldConfiguration battlefieldConfig = new BattlefieldConfiguration(teamInfo); BattleFieldInfo returnedBattleFieldInfo = _factory.GetBattleFieldSetUp(battlefieldConfig); Assert.NotNull(returnedBattleFieldInfo.TerrainInteractables); Assert.AreEqual(0, returnedBattleFieldInfo.TerrainInteractables.ToList().Count); }
public MetadataConfiguration(TeamConfiguration teamConfiguration) { changeDataCaptureAttribute = teamConfiguration.ChangeDataCaptureAttribute; recordSourceAttribute = teamConfiguration.RecordSourceAttribute; loadDateTimeAttribute = teamConfiguration.LoadDateTimeAttribute; expiryDateTimeAttribute = teamConfiguration.ExpiryDateTimeAttribute; eventDateTimeAttribute = teamConfiguration.EventDateTimeAttribute; recordChecksumAttribute = teamConfiguration.RecordChecksumAttribute; etlProcessAttribute = teamConfiguration.EtlProcessAttribute; sourceRowIdAttribute = teamConfiguration.RowIdAttribute; }
public TeamModel GetTeam(Guid collectionId, int projectId) { using (var server = GetServer()) { TfsTeamProjectCollection collection = server.GetTeamProjectCollection(collectionId); WorkItemStore wiStore = collection.GetService <WorkItemStore>(); Project project = wiStore.Projects.GetById(projectId); TeamSettingsConfigurationService configurationService = collection.GetService <TeamSettingsConfigurationService>(); TeamConfiguration config = configurationService.GetTeamConfigurationsForUser(new[] { project.Uri.ToString() }).FirstOrDefault(); //TODO config can be null return(Map(config)); } }
private TeamSettings CreateTargetTeamSettings(TeamConfiguration sourceTCfU) { /////////////////////////////////////////////////// TeamSettings newTeamSettings = sourceTCfU.TeamSettings; newTeamSettings.BacklogIterationPath = newTeamSettings.BacklogIterationPath.Replace(me.Source.Config.Project, me.Target.Config.Project); List<string> newIterationPaths = new List<string>(); foreach (var ip in newTeamSettings.IterationPaths) { newIterationPaths.Add(ip.Replace(me.Source.Config.Project, me.Target.Config.Project)); } newTeamSettings.IterationPaths = newIterationPaths.ToArray(); /////////////////////////////////////////////////// return newTeamSettings; }
private ITfsTeam CreateTfsTeamFromTeamConfiguration(TeamConfiguration teamConfiguration) { return(new TfsTeam(tfsCredentials) { IsDefaultTeam = teamConfiguration.IsDefaultTeam, ProjectUri = teamConfiguration.ProjectUri, TeamId = teamConfiguration.TeamId, TeamName = teamConfiguration.TeamName, TeamSettings = teamConfiguration.TeamSettings, TeamConfiguration = teamConfiguration, TeamSettingsConfigurationService = teamSettingsConfigurationService, TeamService = this.tfsTeamProjectCollection.GetService <TfsTeamService>(), ProjectDetails = projectDetail }); }
public void CorrectNumberOfBattlesBeforeBoss([Range(1, 3)] int numberBattles) { TeamConfiguration bossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Barbarian, 5), new EnemyConfiguration(FighterType.ShieldGuy, 2), new EnemyConfiguration(FighterType.ShieldGuy, 3)); SubRegion subRegion = new SubRegion(WorldSubRegion.Fields, numberBattles, new[] { new ChanceEvent <int>(1, 1) }, new[] { FighterType.Egg }, new BattlefieldConfiguration(bossConfiguration)); SubRegion[] subRegions = { subRegion }; Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions); _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion); for (int i = 0; i < numberBattles; ++i) { Team team = GetSingleEnemyTeam(); _teamFactory.PushTeams(team); _chanceService.PushWhichEventOccurs(0); } _regionManager = GetRegionManager(); IFighter target = TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1); target.PhysicalDamage(target.MaxHealth); _humanFighter1.SetMove(_basicAttackMove, numberBattles); _humanFighter1.SetMoveTarget(target); _chanceService.PushAttackHitsNotCrit(numberBattles); _humanFighter1.SetMove(_runawayMove); _humanFighter2.SetMove(_doNothingMove); _chanceService.PushWhichEventsOccur(0, 0, 0, 0, 0, 0); //used for when the bosses are selecting their moves _regionManager.Battle(_battleManager, _humanTeam); List <Team> enemyTeams = _battleManager.GetAllEnemyTeams(); Assert.AreEqual(numberBattles + 1, enemyTeams.Count); Team bossTeam = enemyTeams[numberBattles]; Assert.AreEqual(3, bossTeam.Fighters.Count); Assert.True(bossTeam.Fighters.Exists(f => f is Barbarian && f.Level == 5)); Assert.True(bossTeam.Fighters.Exists(f => f is ShieldGuy && f.Level == 2)); Assert.True(bossTeam.Fighters.Exists(f => f is ShieldGuy && f.Level == 3)); }
public AreaManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials) { this.projectDetail = projectDetail; this.tfsTeamProjectCollection = TfsApi.Administration.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this.projectDetail.CollectionUri, tfsCredentials); this.teamConfig = this.tfsTeamProjectCollection.GetService<TeamSettingsConfigurationService>(); this.commonStructureService = (ICommonStructureService4)this.tfsTeamProjectCollection.GetService(typeof(ICommonStructureService4)); this.projectInfo = this.commonStructureService.GetProjectFromName(this.projectDetail.ProjectName); foreach (TeamConfiguration item in this.teamConfig.GetTeamConfigurationsForUser(new[] { this.projectInfo.Uri })) { this.teamConfiguration = item; break; } }
public AreaManager(ProjectDetail projectDetail, ITfsCredentials tfsCredentials) { this.projectDetail = projectDetail; this.tfsTeamProjectCollection = TfsApi.Administration.TfsTeamProjectCollectionFactory.GetTeamProjectCollection(this.projectDetail.CollectionUri, tfsCredentials); this.teamConfig = this.tfsTeamProjectCollection.GetService <TeamSettingsConfigurationService>(); this.commonStructureService = (ICommonStructureService4)this.tfsTeamProjectCollection.GetService(typeof(ICommonStructureService4)); this.projectInfo = this.commonStructureService.GetProjectFromName(this.projectDetail.ProjectName); foreach (TeamConfiguration item in this.teamConfig.GetTeamConfigurationsForUser(new[] { this.projectInfo.Uri })) { this.teamConfiguration = item; break; } }
/// <summary> /// Commit the changes to memory, save the configuration settings to disk and create a backup. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveConfigurationFileToolStripMenuItem_Click(object sender, EventArgs e) { #region root path file // Update the paths in memory GlobalParameters.OutputPath = textBoxOutputPath.Text; GlobalParameters.ConfigurationPath = textBoxConfigurationPath.Text; var localEnvironment = (KeyValuePair <TeamWorkingEnvironment, string>)comboBoxEnvironments.SelectedItem; GlobalParameters.WorkingEnvironment = localEnvironment.Key.environmentKey; GlobalParameters.WorkingEnvironmentInternalId = localEnvironment.Key.environmentInternalId; // Save the paths from memory to disk. UpdateRootPathFile(); #endregion // Make sure the new paths as updated are available upon save for backup etc. // Check if the paths and files are available, just to be sure. FileHandling.InitialisePath(GlobalParameters.ConfigurationPath); FileHandling.InitialisePath(GlobalParameters.OutputPath); TeamConfiguration.CreateDummyEnvironmentConfigurationFile(GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension); ValidationSetting.CreateDummyValidationFile(GlobalParameters.ConfigurationPath + GlobalParameters.ValidationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension); JsonExportSetting.CreateDummyJsonConfigurationFile(GlobalParameters.ConfigurationPath + GlobalParameters.JsonExportConfigurationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension); // Create a file backup for the configuration file try { TeamUtility.CreateFileBackup(GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension); richTextBoxInformation.Text = "A backup of the current configuration was made at " + DateTime.Now + " in " + textBoxConfigurationPath.Text + ".\r\n"; } catch (Exception) { richTextBoxInformation.Text = "TEAM was unable to create a backup of the configuration file."; } // Update the in-memory variables for use throughout the application, to commit the saved changes for runtime use. // This is needed before saving to disk, as the EnvironmentConfiguration Class retrieves the values from memory. UpdateConfigurationInMemory(); // Save the information LocalTeamEnvironmentConfiguration.SaveConfigurationFile(); parentFormMain.RevalidateFlag = true; }
private static BattlefieldConfiguration GetBossConfigurationForBossRegion(WorldSubRegion subRegion) { TeamConfiguration teamInfo; TerrainInteractablesConfiguration fieldInfo = null; switch (subRegion) { case WorldSubRegion.Fields: //teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.MegaChicken, 1)); teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, MagicType.Fire), new EnemyConfiguration(FighterType.Egg, 1, MagicType.Ice)); break; case WorldSubRegion.DesertIntro: //teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.Barbarian, 1)); teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, MagicType.Fire), new EnemyConfiguration(FighterType.Egg, 1, MagicType.Ice)); break; //TODO: needs to be filled out case WorldSubRegion.DesertCrypt: case WorldSubRegion.TavernOfHeroes: case WorldSubRegion.AncientLibrary: case WorldSubRegion.Oasis: case WorldSubRegion.CliffsOfAThousandPushups: case WorldSubRegion.TempleOfDarkness: case WorldSubRegion.VillageCenter: case WorldSubRegion.BeastTemple: case WorldSubRegion.Coliseum: case WorldSubRegion.CasinoIntro: case WorldSubRegion.CavesIntro: case WorldSubRegion.DarkCastleIntro: teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.MegaChicken, 1), new EnemyConfiguration(FighterType.ShieldGuy, 1)); break; default: throw new ArgumentOutOfRangeException(nameof(subRegion), subRegion, null); } var ret = new BattlefieldConfiguration(teamInfo, fieldInfo); return(ret); }
public void CorrectlyGeneratesBattlefield_TeamConfiguration_NoTerrainConfiguration() { TeamConfiguration teamInfo = new TeamConfiguration(new EnemyConfiguration(FighterType.Goblin, 1), new EnemyConfiguration(FighterType.Fairy, 1)); BattlefieldConfiguration battlefieldConfig = new BattlefieldConfiguration(teamInfo); BattleFieldInfo returnedBattleFieldInfo = _factory.GetBattleFieldSetUp(battlefieldConfig); List <IFighter> fighters = returnedBattleFieldInfo.EnemyTeam.Fighters; Assert.AreEqual(2, fighters.Count); IFighter firstFighter = fighters[0]; Assert.True(firstFighter is Goblin, $"first fighter should be a Goblin but was {firstFighter.GetType()}"); Assert.True(firstFighter.Level == 1, "first fighter should be level 1"); IFighter secondFighter = fighters[1]; Assert.True(secondFighter is Fairy, $"second fighter should be a fairy but was {secondFighter.GetType()}"); Assert.True(secondFighter.Level == 1, "second fighter should be level 1"); }
private void ProcessMessageByTeam(SlackMessageSubject subject, SlackMessage slackMessage, TeamConfiguration teamConfiguration) { var passingAttachments = slackMessage.Attachments .Where(_ => PassFilter(_, subject, teamConfiguration)).ToArray(); if (passingAttachments.Any()) { var messageToPost = new SlackMessage { Attachments = passingAttachments .Select(_ => TransformMessage(_, subject, teamConfiguration.MessageTransformation)) .ToArray() }; PostMessageToSlack(JsonConvert.SerializeObject(messageToPost), teamConfiguration.SlackUrl); } else { _logger.Log(LogLevel.Information, "Failed to pass the filter."); } }
public BuildCompletedFilter(TeamConfiguration configuration, VstsClient vstsClient) { _configuration = configuration; _vstsClient = vstsClient; }
private bool ConfigurationIsForTeamProjectInScope(TeamConfiguration teamConfiguration) { return string.Compare(projectDetail.ProjectName, teamConfiguration.TeamName, true) == 0; }
private static bool PassFilter(MessageAttachment attachment, SlackMessageSubject subject, TeamConfiguration configuration) { var attachmentFilter = AttachmentFilterFactory.GetAttachmentFilter(subject, configuration, _configuration); return(attachmentFilter != null && attachmentFilter.PassFilter(attachment)); }
/// <summary> /// This method will load an existing configuration file and display the values on the form, or create a new dummy one if not available. /// </summary> /// <param name="chosenFile"></param> private void LocalInitialiseConnections(string chosenFile) { // If the config file does not exist yet, create it by calling the EnvironmentConfiguration Class. if (!File.Exists(chosenFile)) { TeamConfiguration.CreateDummyEnvironmentConfigurationFile(chosenFile); } // Open the configuration file var configList = new Dictionary <string, string>(); var fs = new FileStream(chosenFile, FileMode.Open, FileAccess.Read); var sr = new StreamReader(fs); try { string textline; while ((textline = sr.ReadLine()) != null) { if (textline.IndexOf(@"/*", StringComparison.Ordinal) == -1 && textline.Trim() != "") { var line = textline.Split('|'); configList.Add(line[0], line[1]); } } sr.Close(); fs.Close(); // Databases if (configList["MetadataConnectionId"] != null) { var metadataKey = TeamConfiguration.ConnectionDictionary[configList["MetadataConnectionId"]]; comboBoxMetadataConnection.SelectedIndex = comboBoxMetadataConnection.FindStringExact(metadataKey.ConnectionKey); } Enum.TryParse(configList["EnvironmentMode"], out EnvironmentModes environmentMode); if (environmentMode == EnvironmentModes.PhysicalMode) { radioButtonPhysicalMode.Checked = true; } if (environmentMode == EnvironmentModes.VirtualMode) { radioButtonVirtualMode.Checked = true; } //DWH settings textBoxHubTablePrefix.Text = configList["HubTablePrefix"]; textBoxSatPrefix.Text = configList["SatTablePrefix"]; textBoxLinkTablePrefix.Text = configList["LinkTablePrefix"]; textBoxLinkSatPrefix.Text = configList["LinkSatTablePrefix"]; textBoxDWHKeyIdentifier.Text = configList["KeyIdentifier"]; textBoxEventDateTime.Text = configList["EventDateTimeStamp"]; textBoxLDST.Text = configList["LoadDateTimeStamp"]; textBoxExpiryDateTimeName.Text = configList["ExpiryDateTimeStamp"]; textBoxChangeDataCaptureIndicator.Text = configList["ChangeDataIndicator"]; textBoxRecordSource.Text = configList["RecordSourceAttribute"]; textBoxETLProcessID.Text = configList["ETLProcessID"]; textBoxETLUpdateProcessID.Text = configList["ETLUpdateProcessID"]; textBoxStagingAreaPrefix.Text = configList["StagingAreaPrefix"]; textBoxPSAPrefix.Text = configList["PersistentStagingAreaPrefix"]; textBoxPresentationLayerLabels.Text = configList["PresentationLayerLabels"]; textBoxTransformationLabels.Text = configList["TransformationLabels"]; textBoxSourceRowId.Text = configList["RowID"]; textBoxRecordChecksum.Text = configList["RecordChecksum"]; textBoxCurrentRecordAttributeName.Text = configList["CurrentRecordAttribute"]; textBoxAlternativeRecordSource.Text = configList["AlternativeRecordSource"]; textBoxHubAlternativeLDTSAttribute.Text = configList["AlternativeHubLDTS"]; textBoxSatelliteAlternativeLDTSAttribute.Text = configList["AlternativeSatelliteLDTS"]; textBoxLogicalDeleteAttributeName.Text = configList["LogicalDeleteAttribute"]; //Checkbox setting based on loaded configuration CheckBox myConfigurationCheckBox; if (configList["AlternativeRecordSourceFunction"] == "False") { myConfigurationCheckBox = checkBoxAlternativeRecordSource; myConfigurationCheckBox.Checked = false; textBoxAlternativeRecordSource.Enabled = false; } else { myConfigurationCheckBox = checkBoxAlternativeRecordSource; myConfigurationCheckBox.Checked = true; } if (configList["AlternativeHubLDTSFunction"] == "False") { myConfigurationCheckBox = checkBoxAlternativeHubLDTS; myConfigurationCheckBox.Checked = false; textBoxHubAlternativeLDTSAttribute.Enabled = false; } else { myConfigurationCheckBox = checkBoxAlternativeHubLDTS; myConfigurationCheckBox.Checked = true; } if (configList["AlternativeSatelliteLDTSFunction"] == "False") { myConfigurationCheckBox = checkBoxAlternativeSatLDTS; myConfigurationCheckBox.Checked = false; textBoxSatelliteAlternativeLDTSAttribute.Enabled = false; } else { myConfigurationCheckBox = checkBoxAlternativeSatLDTS; myConfigurationCheckBox.Checked = true; } //Radiobutton setting for prefix / suffix RadioButton myTableRadioButton; if (configList["TableNamingLocation"] == "Prefix") { myTableRadioButton = tablePrefixRadiobutton; myTableRadioButton.Checked = true; } else { myTableRadioButton = tableSuffixRadiobutton; myTableRadioButton.Checked = true; } //Radiobutton settings for on key location RadioButton myKeyRadioButton; if (configList["KeyNamingLocation"] == "Prefix") { myKeyRadioButton = keyPrefixRadiobutton; myKeyRadioButton.Checked = true; } else { myKeyRadioButton = keySuffixRadiobutton; myKeyRadioButton.Checked = true; } //Radiobutton settings for PSA Natural Key determination RadioButton myPsaBusinessKeyLocation; if (configList["PSAKeyLocation"] == "PrimaryKey") { myPsaBusinessKeyLocation = radioButtonPSABusinessKeyPK; myPsaBusinessKeyLocation.Checked = true; } else { myPsaBusinessKeyLocation = radioButtonPSABusinessKeyIndex; myPsaBusinessKeyLocation.Checked = true; } // Also commit the values to memory UpdateConfigurationInMemory(); richTextBoxInformation.AppendText(@"The file " + chosenFile + " was uploaded successfully.\r\n"); } catch (Exception ex) { richTextBoxInformation.AppendText("\r\n\r\nAn error occurred while loading the configuration file. The original error is: '" + ex.Message + "'"); } }
private ITfsTeam CreateTfsTeamFromTeamConfiguration(TeamConfiguration teamConfiguration) { return new TfsTeam(tfsCredentials) { IsDefaultTeam = teamConfiguration.IsDefaultTeam, ProjectUri = teamConfiguration.ProjectUri, TeamId = teamConfiguration.TeamId, TeamName = teamConfiguration.TeamName, TeamSettings = teamConfiguration.TeamSettings, TeamConfiguration = teamConfiguration, TeamSettingsConfigurationService = teamSettingsConfigurationService, TeamService = this.tfsTeamProjectCollection.GetService<TfsTeamService>(), ProjectDetails = projectDetail }; }
public static IAttachmentFilter GetAttachmentFilter(SlackMessageSubject subject, TeamConfiguration teamConfiguration, SlackFilterConfiguration configuration) { switch (subject) { case SlackMessageSubject.BuildCompleted: return(new BuildCompletedFilter(teamConfiguration, new VstsClient(configuration))); case SlackMessageSubject.PullRequestCreated: return(new PullRequestCreatedFilter(teamConfiguration)); case SlackMessageSubject.ReleaseCompleted: return(new ReleaseCompletedFilter(teamConfiguration, new VstsClient(configuration))); default: return(new MessageWithNoFilter()); } }
public PullRequestCreatedFilter(TeamConfiguration configuration) { _configuration = configuration; }
public FormMain() { InitializeComponent(); // Set the version of the build for everything const string versionNumberForTeamApplication = "v1.6.3"; Text = "TEAM - Taxonomy for ETL Automation Metadata " + versionNumberForTeamApplication; GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The TEAM root path is {GlobalParameters.RootPath}.")); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The TEAM script path is {GlobalParameters.ScriptPath}.")); richTextBoxInformation.AppendText("Initialising the application.\r\n\r\n"); // Root paths (mandatory TEAM directories) // Make sure the application and custom location directories exist as per the start-up default. try { LocalTeamEnvironmentConfiguration.InitialiseEnvironmentPaths(); } catch (Exception ex) { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An error was encountered while creating the standard TEAM paths: \r\n\r\n{ex}")); } #region Load the root path configuration settings (user defined paths and working environment) // Load the root file, to be able to locate the (customisable) configuration file. // This file contains the configuration directory, the output directory and the working environment. string rootPathFileName = GlobalParameters.CorePath + GlobalParameters.PathFileName + GlobalParameters.FileExtension; try { LocalTeamEnvironmentConfiguration.LoadRootPathFile(rootPathFileName, GlobalParameters.ConfigurationPath, GlobalParameters.OutputPath); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The core configuration file {rootPathFileName} has been loaded.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"The core configuration file {rootPathFileName} could not be loaded. Is there a Configuration directory in the TEAM installation location?")); } // Environments file string environmentFile = GlobalParameters.CorePath + GlobalParameters.JsonEnvironmentFileName + GlobalParameters.JsonExtension; try { TeamEnvironmentCollection.LoadTeamEnvironmentCollection(environmentFile); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The environment file {environmentFile} has been loaded.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"The environment file {environmentFile} could not be loaded. Does the file exists in the designated (root) location?")); } #endregion #region Check if user configured paths exists (now that they have been loaded from the root file), and create dummy Configuration and Validation files if necessary // Configuration Path try { FileHandling.InitialisePath(GlobalParameters.ConfigurationPath); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user defined configuration path {GlobalParameters.ConfigurationPath} is available.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The directories required to operate TEAM are not available and can not be created. Do you have administrative privileges in the installation directory to create these additional directories?")); } // Output Path try { FileHandling.InitialisePath(GlobalParameters.OutputPath); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user defined output path {GlobalParameters.OutputPath} is available.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "The directories required to operate TEAM are not available and can not be created. Do you have administrative privileges in the installation directory to create these additional directories?")); } // Create a dummy configuration file if it does not exist. var configurationFileName = GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; try { if (!File.Exists(configurationFileName)) { TeamConfiguration.CreateDummyEnvironmentConfigurationFile(configurationFileName); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"A new configuration file {configurationFileName} was created.")); } else { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The existing configuration file {configurationFileName} was detected.")); } } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {configurationFileName}.")); } // Create a default validation file if the file does not exist as expected. var validationFileName = GlobalParameters.ConfigurationPath + GlobalParameters.ValidationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; try { ValidationSetting.CreateDummyValidationFile(validationFileName); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {validationFileName}.")); } // Create a default json configuration file if the file does not exist as expected. var jsonConfigurationFileName = GlobalParameters.ConfigurationPath + GlobalParameters.JsonExportConfigurationFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; try { JsonExportSetting.CreateDummyJsonConfigurationFile(jsonConfigurationFileName); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered creating or detecting the configuration paths for {jsonConfigurationFileName}.")); } #endregion // Load the connections file for the respective environment. var connectionFileName = GlobalParameters.ConfigurationPath + GlobalParameters.JsonConnectionFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.JsonExtension; TeamConfiguration.ConnectionDictionary = TeamConnectionFile.LoadConnectionFile(connectionFileName); #region Load configuration file // Load the available configuration file into memory. var configurationFile = GlobalParameters.ConfigurationPath + GlobalParameters.ConfigFileName + '_' + GlobalParameters.WorkingEnvironment + GlobalParameters.FileExtension; try { // Load the configuration file. TeamConfiguration.LoadTeamConfigurationFile(configurationFile); GlobalParameters.EnvironmentMode = TeamConfiguration.EnvironmentMode; // Retrieve the events into the main event log. GlobalParameters.TeamEventLog.MergeEventLog(TeamConfiguration.ConfigurationSettingsEventLog); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, $"The user configuration settings ({configurationFile}) have been loaded.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, $"An issue was encountered loading the user configuration file ({configurationFile}).")); } #endregion //FormBase.EnvironmentVersion.GetEnvironmentVersionsFromFile(Path.GetDirectoryName(configurationFile)); TeamVersionList.LoadVersionList(GlobalParameters.CorePath + GlobalParameters.VersionFileName + GlobalParameters.JsonExtension); // Load the pattern definition file. try { GlobalParameters.PatternDefinitionList = LoadPatternDefinition.DeserializeLoadPatternDefinition(GlobalParameters.LoadPatternPath + GlobalParameters.LoadPatternDefinitionFile); GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Information, "The pattern definition file was loaded successfully.")); } catch { GlobalParameters.TeamEventLog.Add(Event.CreateNewEvent(EventTypes.Error, "An issue was encountered loading the pattern definition file.")); } // Report the events (including errors) back to the user int errorCounter = 0; foreach (Event individualEvent in GlobalParameters.TeamEventLog) { if (individualEvent.eventCode == (int)EventTypes.Error) { errorCounter++; } } if (errorCounter > 0) { richTextBoxInformation.AppendText( $"{errorCounter} error(s) have been found at startup. Please check the Event Log in the menu.\r\n\r\n"); } TestConnections(); //Startup information richTextBoxInformation.AppendText("\r\nApplication initialised - the Taxonomy of ETL Automation Metadata (TEAM). \r\n"); richTextBoxInformation.AppendText("Welcome to version " + versionNumberForTeamApplication + ".\r\n\r\n"); labelWorkingEnvironment.Text = GlobalParameters.WorkingEnvironment; //+"("+GlobalParameters.WorkingEnvironmentInternalId+")"; labelEnvironmentMode.Text = GlobalParameters.EnvironmentMode.ToString(); }
private void ReadAndMapAllSettings() { SlackConfiguration.Initialize(m_appSettings, this); TeamConfiguration.Initialize(m_appSettings, this); ZoomConfiguration.Initialize(m_appSettings, this); }
public Team GetTeam(TeamConfiguration configuration) { return(_teams.Count > 0 ? _teams.Dequeue() : _realTeamFactory.GetTeam(configuration)); }