Пример #1
0
        public void TestScenarioCreationFromAction()
        {
            var provider = new Mock <IWebDriverProvider>();
            var factory  = new ScenarioFactory(provider.Object);
            var action   = new TrainArmyAction
            {
                UnitsToTrain = new Dictionary <string, int> {
                    { "test", 1 }
                }
            };

            var scenario = factory.GetScenario(action);

            Assert.NotNull(scenario);
            Assert.AreEqual(typeof(TrainArmyScenario), scenario.GetType());

            var buildAction = new BuildAction
            {
                BuildingId = "testBuilding"
            };

            var buildScenario = factory.GetScenario(buildAction);

            Assert.NotNull(buildScenario);
            Assert.AreEqual(typeof(BuildScenario), buildScenario.GetType());
        }
Пример #2
0
        static void Main(string[] args)
        {
            Scenario scenario = null;

            try
            {
                scenario = ScenarioFactory.GetScenario(Scenarios.CreateSingleVmExample);
                scenario.Execute();
            }
            finally
            {
                var client = new ResourcesManagementClient(scenario.Context.SubscriptionId, scenario.Context.Credential);
                foreach (var rgId in Scenario.CleanUp)
                {
                    var name = GetResourceName(rgId);
                    try
                    {
                        var rg = client.ResourceGroups.Get(name).Value;
                        if (rg != null)
                        {
                            Console.WriteLine($"--------Deleting {rg.Name}--------");
                            _ = client.ResourceGroups.StartDelete(rg.Name).WaitForCompletionAsync().ConfigureAwait(false).GetAwaiter().GetResult();
                        }
                    }
                    catch
                    {
                        // ignore errors in get/delete
                    }
                }
            }
        }