示例#1
0
        protected override bool Matches(Scenario scenario)
        {
            RunScenario runScenario = scenario as RunScenario;
            if (runScenario == null) return false;

            return (mPersonality == runScenario.mPersonality);
        }
        public void ThenCanRenderTags()
        {
            var configuration = Container.Resolve<Configuration>();

            var scenario = new Scenario
                              {
                                  Name = "A Scenario",
                                  Description = @"This scenario has tags",
                                  Tags = { "tag1", "tag2" }
                              };

            var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
            XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
            XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");

            Check.That(header).IsNotNull();
            Check.That(header).IsNamed("div");
            Check.That(header).IsInNamespace("http://www.w3.org/1999/xhtml");
            Check.That(header).HasAttribute("class", "scenario-heading");
            Check.That(header.Elements().Count()).IsEqualTo(3);

            Check.That(header.Elements().ElementAt(0)).IsNamed("h2");
            Check.That(header.Elements().ElementAt(1)).IsNamed("p");
            Check.That(header.Elements().ElementAt(2)).IsNamed("div");

            var tagsParagraph = header.Elements().ElementAt(1);

            Check.That(tagsParagraph.ToString()).IsEqualTo(
              @"<p class=""tags"" xmlns=""http://www.w3.org/1999/xhtml"">Tags: <span>tag1</span>, <span>tag2</span></p>");
        }
        //missing:
        //- action can't be before first observation -> interface validation!
        public int AddFirstLevel(World.WorldDescription WorldDescription, Scenario.ScenarioDescription ScenarioDescription, out int numberOfImpossibleLeaf)
        {
            numberOfImpossibleLeaf = 0;
            int t = 0;

            //states
            List<string> fluentNames = WorldDescription.GetFluentNames().ToList<string>();
            List<State> states = CreateStatesBasedOnObservations(fluentNames, ScenarioDescription, ref t);

            if (states.Count == 0)
            {
                numberOfImpossibleLeaf = 0;
                return 0;
            }

            foreach (var state in states)
            {
                Vertex newVertex = new Vertex(state, null, t, null);
                LastLevel.Add(newVertex);
            }

            //action
            WorldAction worldAction = ScenarioDescription.GetActionAtTime(t);
            if (worldAction != null)
                for (int i = 0; i < LastLevel.Count; ++i)
                {
                    LastLevel[i].ActualWorldAction = (WorldAction)worldAction.Clone();
                    if (!WorldDescription.Validate(LastLevel[i]))
                    {
                        ++numberOfImpossibleLeaf;
                    }
                }
            return t;
        }
示例#4
0
        public XElement Format(Scenario scenario, int id)
        {
          var header = new XElement(
            this.xmlns + "div", 
            new XAttribute("class", "scenario-heading"), 
            new XElement(this.xmlns + "h2", scenario.Name));

          var tags = RetrieveTags(scenario);
          if (tags.Length > 0)
          {
            var paragraph = new XElement(this.xmlns + "p", CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns));
            paragraph.Add(new XAttribute("class", "tags"));
            header.Add(paragraph);
          }

          header.Add(this.htmlDescriptionFormatter.Format(scenario.Description));

          return new XElement(
            this.xmlns + "li",
            new XAttribute("class", "scenario"),
            this.htmlImageResultFormatter.Format(scenario),
            header,
            new XElement(
              this.xmlns + "div",
              new XAttribute("class", "steps"),
              new XElement(
                this.xmlns + "ul",
                scenario.Steps.Select(step => this.htmlStepFormatter.Format(step))))
            );
        }
 public string GetScenarioId(Scenario scenario)
 {
     var id = string.Format("scenario-{0}", _currentScenarioNumber);
    _currentScenarioNumber++;
     _currentStepNumber = 1;
     return id;
 }
示例#6
0
        string ScenarioCodeFrom(Scenario Scenario)
        {
            var StepCode = Scenario.Steps.Aggregate("",
                (Steps, Step) => Steps + ExecuteStep(Step));

            return string.Format(ScenarioDeclaration, Scenario.Name, StepCode);
        }
        void ReportOnStep(Scenario scenario, Step step)
        {
            var message =
                string.Format
                    ("\t{0}  [{1}] ",
                    PrefixWithSpaceIfRequired(step).PadRight(_longestStepSentence + 5),
                    Configurator.Scanners.Humanize(step.Result.ToString()));

            // if all the steps have passed, there is no reason to make noise
            if (scenario.Result == Result.Passed)
                message = "\t" + PrefixWithSpaceIfRequired(step);

            if (step.Exception != null)
            {
                _exceptions.Add(step.Exception);

                var exceptionReference = string.Format("[Details at {0} below]", _exceptions.Count);
                if (!string.IsNullOrEmpty(step.Exception.Message))
                    message += string.Format("[{0}] {1}", FlattenExceptionMessage(step.Exception.Message), exceptionReference);
                else
                    message += string.Format("{0}", exceptionReference);
            }

            if (step.Result == Result.Inconclusive || step.Result == Result.NotImplemented)
                Console.ForegroundColor = ConsoleColor.Yellow;
            else if (step.Result == Result.Failed)
                Console.ForegroundColor = ConsoleColor.Red;
            else if (step.Result == Result.NotExecuted)
                Console.ForegroundColor = ConsoleColor.Gray;

            Console.WriteLine(message);
            Console.ForegroundColor = ConsoleColor.White;
        }
        public void ThenSingleScenarioWithStepsAddedSuccessfully()
        {
            var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>();
            var scenario = new Scenario
                               {
                                   Name = "Test Feature",
                                   Description =
                                       "In order to test this feature,\nAs a developer\nI want to test this feature"
                               };
            var given = new Step {NativeKeyword = "Given", Name = "a precondition"};
            var when = new Step {NativeKeyword = "When", Name = "an event occurs"};
            var then = new Step {NativeKeyword = "Then", Name = "a postcondition"};
            scenario.Steps = new List<Step>(new[] {given, when, then});

            using (var workbook = new XLWorkbook())
            {
                IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1");
                int row = 3;
                excelScenarioFormatter.Format(worksheet, scenario, ref row);

                worksheet.Cell("B3").Value.ShouldEqual(scenario.Name);
                worksheet.Cell("C4").Value.ShouldEqual(scenario.Description);
                row.ShouldEqual(8);
            }
        }
示例#9
0
 public override FreeDocument DictSerialize(Scenario scenario = Scenario.Database)
 {
     FreeDocument dict = base.DictSerialize(scenario);
     dict.Children = new List<FreeDocument>();
     dict.Children.AddRange(Projects.Select(d => d.DictSerialize(scenario)));
     return dict;
 }
示例#10
0
        public void Should_add_table_steps_to_scenario()
        {
            var gherkinEvents = MockRepository.GenerateStub<IGherkinParserEvents>();
            var stepBuilder = new StepBuilder(gherkinEvents);
            var feature = new Feature("title");
            var scenario = new Scenario("title", "source", feature);
            gherkinEvents.Raise(_ => _.FeatureEvent += null, this, new EventArgs<Feature>(feature));
            gherkinEvents.Raise(_ => _.ScenarioEvent += null, this, new EventArgs<Scenario>(scenario));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 1", "source")));
            gherkinEvents.Raise(_ => _.StepEvent += null, this, new EventArgs<StringStep>(new StringStep("step 2", "source")));
            gherkinEvents.Raise(_ => _.TableEvent += null, this,
                                new EventArgs<IList<IList<Token>>>(new List<IList<Token>>
                                                                       {
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("A", new LineInFile(1)),
                                                                                   new Token("B", new LineInFile(1))
                                                                               },
                                                                           new List<Token>
                                                                               {
                                                                                   new Token("1", new LineInFile(2)),
                                                                                   new Token("2", new LineInFile(2))
                                                                               },

                                                                       }));
            gherkinEvents.Raise(_ => _.EofEvent += null, this, new EventArgs());

            Assert.That(scenario.Steps.Count(), Is.EqualTo(2));
            Assert.That(scenario.Steps.ToList()[0], Is.TypeOf<StringStep>());
            Assert.That(scenario.Steps.ToList()[1], Is.TypeOf<StringTableStep>());
        }
示例#11
0
        private void LoadScenario(XmlReader reader, Scenario scenario)
        {
            while (!reader.EOF && reader.NodeType != XmlNodeType.EndElement)
            {
                if (reader.NodeType == XmlNodeType.Element && reader.Name == "Stack")
                {
                    var stack = new Stack();
                    scenario.Stacks[reader.GetAttribute("name")] = stack;

                    var stackAttributes = new Dictionary<string, string>();
                    if (reader.MoveToFirstAttribute())
                    {
                        for (; ; )
                        {
                            if (reader.Name != "name")
                                stackAttributes.Add(reader.Name, reader.Value);
                            if (!reader.MoveToNextAttribute())
                                break;
                        }
                        reader.MoveToElement();
                    }

                    reader.ReadStartElement("Stack");
                    LoadStack(reader, stack);
                    reader.ReadEndElement();

                    foreach (var attr in stackAttributes)
                        _stackDecorator[attr.Key](stack, attr.Value);
                }
                else
                {
                    reader.Read();
                }
            }
        }
示例#12
0
 public StepBuilder(IGherkinParserEvents gherkinEvents)
 {
     gherkinEvents.ScenarioEvent += (s, e) =>
                                        {
                                            HandlePreviousEvent();
                                            scenario = e.EventInfo;
                                        };
     gherkinEvents.StepEvent += (s, e) =>
                                    {
                                        HandlePreviousEvent();
                                        previousStep = e.EventInfo;
                                    };
     gherkinEvents.DocStringEvent += (s, e) => HandleDocString(e.EventInfo);
     gherkinEvents.FeatureEvent += (s, e) => HandlePreviousEventAndCleanUp();
     gherkinEvents.ExamplesEvent += (s, e) => HandlePreviousEvent();
     gherkinEvents.BackgroundEvent += (s, e) =>
                                          {
                                              HandlePreviousEvent();
                                              scenario = e.EventInfo;
                                          };
     gherkinEvents.TableEvent += (s, e) =>
                                     {
                                         HandleTableEvent(e.EventInfo);
                                         previousStep = null;
                                     };
     gherkinEvents.TagEvent += (s, e) => HandlePreviousEvent();
     gherkinEvents.EofEvent += (s, e) => HandlePreviousEventAndCleanUp();
 }
示例#13
0
 private IEnumerable<StepResult> RunBackground(Scenario background)
 {
     return RunSteps(background.Steps, ctx => { }, ctx => { })
         .Select(_ => new BackgroundStepResult(background.Title, _))
         .Cast<StepResult>()
         .ToList();
 }
示例#14
0
 private ScenarioResult RunExamples(Scenario scenario)
 {
     var runner = new ExampleRunner();
     Func<IEnumerable<StringStep>, IEnumerable<StepResult>> runSteps = steps => RunSteps(steps, BeforeStep, AfterStep);
     var exampleResults = runner.RunExamples(scenario, runSteps, BeforeScenario, AfterScenario);
     return exampleResults;
 }
示例#15
0
        public void Format(XElement parentElement, Scenario scenario)
        {
            var section = new XElement("section",
                                       new XElement("title", scenario.Name));

            if (this.configuration.HasTestResults)
            {
                TestResult testResult = this.nunitResults.GetScenarioResult(scenario);
                if (testResult.WasExecuted && testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario passed"));
                }
                else if (testResult.WasExecuted && !testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario failed"));
                }
            }

            if (!string.IsNullOrEmpty(scenario.Description))
            {
                section.Add(new XElement("p", scenario.Description));
            }

            foreach (Step step in scenario.Steps)
            {
                this.ditaStepFormatter.Format(section, step);
            }

            parentElement.Add(section);
        }
示例#16
0
        public static void Execute(Scenario scenario, Actor actor)
        {
            Precondition.Requires(
                scenario != null,
                Properties.Resources.USE_CASE_SCENARIO_CANNOT_BE_NULL
                );

            Precondition.Requires(
                actor != null,
                Properties.Resources.USE_CASE_ACTOR_CANNOT_BE_NULL
                );

            try
            {
                if (!scenario.Authorize(actor))
                {
                    throw new AuthorizationException(Properties.Resources.USER_AUTHORIZATION_FAILED);
                }

                scenario.Execute();
            }
            catch (DomainException)
            {
                throw;
            }
            catch (Exception exc)
            {
                throw new DomainException(exc.Message, exc);
            }
        }
 /// <summary>
 /// Create a new scenario with the given title, ensuring the previous scenario was properly
 /// cleaned up. Suggested if you use MBUnit or NUnit to
 /// create a base class with a method 'Scenario()' which uses the current test's naame. E.g.
 /// 
 /// protected Scenario(){
 ///    return Scenario(TestContext.CurrentContext.Test.Name);
 /// }
 /// </summary>
 /// <param name="title">the scenario title. Can not be empty or null</param>
 /// <returns>a newly created scenario</returns>
 public Scenario Scenario(String title)
 {
     //ensure previous scenario has completed to prevent dangling scenarios
     //i.e. those which look like they have passed but haven't actually run
     if (CurrentScenario != null) 
     { 
         try
         {
             AfterTest();
         }
         catch (AssertionFailedException e)
         {
             throw new AssertionFailedException("Previous Scenario failed", e);
         }
         BeforeTest();
     }
     if (String.IsNullOrWhiteSpace(title))
     {
         TestFirstAssert.Fail("Scenario's require a title");
     } 
     //Console.WriteLine("New Scenario:" + title);
     OnBeforeNewScenario();
     CurrentScenario = new Scenario(title, Injector);      
     return CurrentScenario;
 }
示例#18
0
        public void Format(Body body, Scenario background)
        {
            var headerParagraph   = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" }));
            var backgroundKeyword = GetLocalizedBackgroundKeyword();
            headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword)));

            var table = new Table();
            table.Append(GenerateTableProperties());
            var row = new TableRow();
            var cell = new TableCell();
            cell.Append(headerParagraph);

            foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description))
            {
                cell.Append(CreateNormalParagraph(descriptionSentence));
            }

            foreach (var step in background.Steps)
            {
                cell.Append(WordStepFormatter.GenerateStepParagraph(step));
            }

            cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line?
            row.Append(cell);
            table.Append(row);

            body.Append(table);
        }
示例#19
0
        public void NoTags()
        {
            var configuration = Container.Resolve<Configuration>();
              configuration.TestResultsFiles = null;

              var scenario = new Scenario
              {
            Name = "A Scenario",
            Description = @"This scenario has no tags",
            Tags = { }
              };

              var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>();
              XElement featureElement = htmlFeatureFormatter.Format(scenario, 1);
              XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div");

              Assert.NotNull(header);
              header.ShouldBeNamed("div");
              header.ShouldBeInInNamespace("http://www.w3.org/1999/xhtml");
              header.ShouldHaveAttribute("class", "scenario-heading");
              Assert.AreEqual(2, header.Elements().Count());

              header.Elements().ElementAt(0).ShouldBeNamed("h2");
              header.Elements().ElementAt(1).ShouldBeNamed("div");
        }
示例#20
0
 public void Should_update_scenarioContext_with_info_from_ScenarioCreated()
 {
     const string scenarioTitle = "scenario title";
     var scenario = new Scenario(scenarioTitle, "", new Feature("ignored"));
     sut.OnScenarioStartedEvent(scenario);
     Assert.That(scenarioContext.ScenarioTitle, Is.EqualTo(scenarioTitle));
 }
示例#21
0
 public override void DictDeserialize(IDictionary<string, object> docu, Scenario scenario = Scenario.Database)
 {
     base.DictDeserialize(docu);
     TableSelector.SelectItem =
         dataManager.DataCollections.FirstOrDefault(d => d.Name == docu["Table"].ToString());
     TableSelector.InformPropertyChanged("");
 }
示例#22
0
 public virtual void DictDeserialize(IDictionary<string, object> docu, Scenario scenario = Scenario.Database)
 {
     ProcessToDo.DictDeserialize(docu, scenario);
     Name = docu.Set("Name", Name);
     Description = docu.Set("Description", Description);
     CreateTime = docu.Set("CreateTime", CreateTime);
     ScriptPath = docu.Set("ScriptPath", ScriptPath);
 }
示例#23
0
        public override FreeDocument DictSerialize(Scenario scenario = Scenario.Database)
        {
            var dict = base.DictSerialize(scenario);
            if(TableSelector.SelectItem!=null)
              dict.Add("Table", TableSelector.SelectItem.Name);

            return dict;
        }
 public void Write(Scenario.Model.ScenarioModel scenario)
 {
     using (Stream stream = File.Open(_path, FileMode.Create))
     {
         BinaryFormatter bformatter = new BinaryFormatter();
         bformatter.Serialize(stream, scenario);
     }
 }
示例#25
0
 public ExamplesBuilder(IGherkinParserEvents gherkinEvents)
 {
     gherkinEvents.FeatureEvent += (s, e) => Cleanup();
     gherkinEvents.EofEvent += (s, e) => Cleanup();
     gherkinEvents.ScenarioEvent += (sender, evt) => { scenario = evt.EventInfo; };
     gherkinEvents.ExamplesEvent += (sender, evt) => { listenToParsedTable = true; };
     gherkinEvents.TableEvent += (sender, evt) => ExtractExamplesFromTable(evt.EventInfo);
 }
        public object Visit(Scenario n)
        {
            if (this.root == null) return false;

            var titleAttribute = root.Attribute(XName.Get("Title"));
            n.Title = (titleAttribute != null) ? titleAttribute.Value : String.Empty;

            var descriptionAttribute = root.Attribute(XName.Get("Description"));
            n.Description = (descriptionAttribute != null) ? descriptionAttribute.Value : String.Empty;

            var authorAttribute = root.Attribute(XName.Get("Author"));
            n.Author = (authorAttribute != null) ? authorAttribute.Value : String.Empty;

            var creationDateAttribute = root.Attribute(XName.Get("CreationDate"));
            n.CrationDate = (creationDateAttribute != null) ? Convert.ToDateTime(creationDateAttribute.Value) : DateTime.Now;

            var ratingAttribute = root.Attribute(XName.Get("Rating"));
            n.Rating = (ratingAttribute != null) ? Convert.ToDouble(ratingAttribute.Value) : 0.0;


            //inputs
            var inputElements = root.Element(XName.Get("Inputs"));
            if (inputElements != null)
            {
                foreach (var inputElement in inputElements.Elements())
                {
                    var newInput = new InputCellData();
                    newInput.Accept(new XMLToScenarioVisitor(inputElement));
                    n.Inputs.Add(newInput);
                }
            }

            //intermediates
            var intermediateElements = root.Element(XName.Get("Intermediates"));
            if (intermediateElements != null)
            {
                foreach (var intermediateElement in intermediateElements.Elements())
                {
                    var newIntermediate = new IntermediateCellData();
                    newIntermediate.Accept(new XMLToScenarioVisitor(intermediateElement));
                    n.Intermediates.Add(newIntermediate);
                }
            }

            //results
            var resultElements = root.Element(XName.Get("Results"));
            if (resultElements != null)
            {
                foreach (var resultElement in resultElements.Elements())
                {
                    var newResult = new ResultCellData();
                    newResult.Accept(new XMLToScenarioVisitor(resultElement));
                    n.Results.Add(newResult);
                }
            }

            return true;
        }
示例#27
0
        private ScenarioResult RunExample(Scenario scenario, Func<IEnumerable<StringStep>, IEnumerable<StepResult>> runSteps, Example example)
        {
            var steps = BuildSteps(scenario, example);

            var scenarioResult = new ScenarioResult(scenario.Feature, scenario.Title);
            var stepResults = runSteps(steps);
            scenarioResult.AddActionStepResults(stepResults);
            return scenarioResult;
        }
示例#28
0
 public virtual FreeDocument DictSerialize(Scenario scenario = Scenario.Database)
 {
     var docu = ProcessToDo.DictSerialize(scenario);
     docu.SetValue("CreateTime", CreateTime);
     docu.SetValue("Name", Name);
     docu.SetValue("Description", Description);
     docu.SetValue("ScriptPath", ScriptPath);
     return docu;
 }
示例#29
0
文件: DbEx.cs 项目: CHERRISHGRY/Hawk
 public override void DictDeserialize(IDictionary<string, object> docu, Scenario scenario = Scenario.Database)
 {
     base.DictDeserialize(docu);
     ConnectorSelector.SelectItem =
         dataManager.CurrentConnectors.FirstOrDefault(d => d.Name == docu["Connector"].ToString());
     var connector = ConnectorSelector.SelectItem;
     if (connector == null)
         return;
 }
示例#30
0
    public TestResult GetScenarioResult(Scenario scenario)
    {
      Parser.JsonResult.Element cucumberScenario  = null;
      var cucumberFeature = this.GetFeatureElement(scenario.Feature);
      if(cucumberFeature != null)
        cucumberScenario = cucumberFeature.elements.FirstOrDefault(x => x.name == scenario.Name);
      return this.GetResultFromScenario(cucumberScenario);

    }
示例#31
0
 public void FileCopyWithOverwriteThrow()
 => Scenario
 .Given(I.start_with_a_clean_directory)
 .When(() => I.use_overwrite_mode(Overwrite.Throw).to_copy_from(@"bar\baz.txt").to("sub"))
 .Then(() => it.should_have_thrown <InvalidOperationException>());
示例#32
0
 public void DeepDirectoryCopy()
 => Scenario
 .Given(I.start_with_a_clean_directory)
 .When(() => I.make_a_deep_copy_from("bar").to("sub"))
 .Then(() => the.content_of_directory("sub").should_be("bar", "subsub", "baz.txt", "binary.bin", "notes.txt"))
 .And(() => the.content_of_directory(@"sub\bar").should_be("deep.txt"));
        private CodeMemberMethod CreateTestMethod(TestClassGenerationContext generationContext, Scenario scenario, Tags additionalTags)
        {
            CodeMemberMethod testMethod = CreateMethod(generationContext.TestClass);

            SetupTestMethod(generationContext, testMethod, scenario, additionalTags);

            return(testMethod);
        }
示例#34
0
        private Lines Scenario(Scenario scenario)
        {
            var scenarioBlock = new ScenarioBlock(scenario, style);

            return(scenarioBlock.Lines);
        }
示例#35
0
 public DownstreamRequestBuilder WithScenario(Scenario scenario)
 {
     _request.Scenario = scenario;
     return(this);
 }
示例#36
0
 internal static Scenario ReplaceQuickstartScenarioIfNeeded(Scenario original)
 {
     return(mapGenerationPending ? TryGetScenarioByName(Settings.ScenarioToGen) : original);
 }
示例#37
0
 private void Awake()
 {
     instance = this;
 }
示例#38
0
 public Step CreateStep(Step newStep, Scenario scenario)
 {
     _context.Where(s => s.Id == scenario.Id).FirstOrDefault()
     .StepList.Add(newStep);
     return(newStep);
 }
示例#39
0
 public void CopyNewerFileWithOverwriteIfNewer()
 => Scenario
 .Given(I.start_with_a_clean_directory)
 .When(() => I.use_overwrite_mode(Overwrite.IfNewer).to_copy_from(@"sub\baz.txt").to("bar"))
 .Then(() => the.content_of(@"bar\baz.txt").should_be_the_text("sub baz"))
 .And(() => the.content_of(@"sub\baz.txt").should_be_the_text("sub baz"));
示例#40
0
 public Step GetStepById(int id, Scenario scenario) =>
 _context.Where(s => s.Id == scenario.Id)
 .FirstOrDefault().StepList.Where(l => l.Id == id).FirstOrDefault();
示例#41
0
    public ScenarioPlayScreen(Scenario selectedScenario)
    {
        CommandIcon = ResourceManager.GetIconTexture("Icon_CommandPoint");
        MoneyIcon   = ResourceManager.GetIconTexture("Icon_Money");

        PlayerFleet  = new FleetData();
        EnemyFleet   = new FleetData();
        AlliedFleet  = new FleetData();
        NeutralFleet = new FleetData();

        PlayerShipManager  = new ShipManager(true, PlayerFleet, 9);
        EnemyShipManager   = new ShipManager(false, EnemyFleet, 10);
        AlliedShipManager  = new ShipManager(false, AlliedFleet, 11);
        NeutralShipManager = new ShipManager(false, NeutralFleet, 13);

        ShipManagers.Add(PlayerShipManager);
        ShipManagers.Add(EnemyShipManager);
        ShipManagers.Add(AlliedShipManager);
        ShipManagers.Add(NeutralShipManager);

        PlayerShipManager.SetPause(true);
        EnemyShipManager.SetPause(true);
        AlliedShipManager.SetPause(true);
        NeutralShipManager.SetPause(true);
        EnemyShipManager.SetAI(true);
        AlliedShipManager.SetAI(true);

        //Set Combat diplomacy
        PlayerShipManager.AddEnemyShipManager(EnemyShipManager);
        PlayerShipManager.AddAlliedShipManager(AlliedShipManager);
        EnemyShipManager.AddEnemyShipManager(PlayerShipManager);
        EnemyShipManager.AddEnemyShipManager(AlliedShipManager);
        AlliedShipManager.AddEnemyShipManager(EnemyShipManager);
        AlliedShipManager.AddAlliedShipManager(PlayerShipManager);

        shipDragSelectionBox = new ShipDragSelectionBox();

        float toolTipWidth = Screen.width * 0.175f;

        ToolTip = new GUIToolTip(new Vector2(Screen.width - toolTipWidth, 0), toolTipWidth);

        float MiniMapSize = Screen.height * 0.2f;
        Rect  miniMapRect = new Rect(Screen.width - Screen.height * 0.215f, Screen.height - Screen.height * 0.215f, MiniMapSize, MiniMapSize);

        miniMap = new MiniMap(miniMapRect, GameManager.instance.miniMapTexture, ToolTip);
        float GameSpeedButtonSize = miniMapRect.width / 5f;

        gameSpeedButton = new GameSpeedButton(new Rect(miniMapRect.x - GameSpeedButtonSize, miniMapRect.yMax - GameSpeedButtonSize, GameSpeedButtonSize, GameSpeedButtonSize), ToolTip);

        Vector2 shipPanelSize = new Vector2(Screen.width * 0.5f, Screen.height * 0.25f);

        shipInfoPanel = new ShipCombatInfoPanel(this, new Rect(new Vector2((Screen.width - shipPanelSize.x) / 2, Screen.height - shipPanelSize.y), shipPanelSize), PlayerShipManager, ToolTip);

        SetupPanel = new Rect(0, 0, Screen.width * 0.25f, Screen.height * 0.6f);

        Rect battleTimerRect = new Rect(Screen.width * 0.475f, 0, Screen.width * 0.05f, Screen.height * 0.03f);

        combatTimer = new CombatTimer(battleTimerRect, ToolTip);

        shipHullList = new ShipHullScrollList(new Rect(SetupPanel.width * 0.1f, SetupPanel.height * 0.01f, SetupPanel.width * 0.8f, SetupPanel.height * 0.375f), ChangeHull, CheckHullValid);

        DesignScrollWindowRect = new Rect(shipHullList.getRect().x, shipHullList.getRect().yMax + SetupPanel.height * 0.01f, shipHullList.getRect().width, shipHullList.getRect().height);
        DesignScrollViewRect   = new Rect(0, 0, DesignScrollWindowRect.width * 0.92f, DesignScrollWindowRect.height * 1.02f);
        DesignScrollPostion    = Vector2.zero;

        CommandRect     = new Rect((SetupPanel.width - GameManager.instance.StandardLabelSize.x) / 2f, DesignScrollWindowRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardLabelSize.x, GameManager.instance.StandardLabelSize.y);
        MoneyRect       = new Rect(CommandRect.x, CommandRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardLabelSize.x, GameManager.instance.StandardLabelSize.y);
        StartButtonRect = new Rect((SetupPanel.width - GameManager.instance.StandardButtonSize.x * 2) / 4f, MoneyRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        BackButtonRect  = new Rect((SetupPanel.width / 2f) + (SetupPanel.width - GameManager.instance.StandardButtonSize.x * 2) / 4f, StartButtonRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);

        //Summary
        SummaryScrollList = new CombatSummaryScrollList();

        //Pause
        Vector2 pauseButtonSize = new Vector2(Screen.width * 0.078125f, Screen.height * 0.037037f);

        ContinueButtonRect = new Rect((Screen.width - pauseButtonSize.x) / 2f, Screen.height / 3.5f, pauseButtonSize.x, pauseButtonSize.y);
        QuitButtonRect     = new Rect(ContinueButtonRect.x, ContinueButtonRect.yMax, pauseButtonSize.x, pauseButtonSize.y);

        shipHullList.CheckFirstHull(ChangeHull);

        LoadScenario(selectedScenario);
    }
示例#42
0
 public ScenarioExecutor(Scenario scenario)
 {
     _scenario = scenario;
 }
 public Scenario Post(Scenario scenario)
 {
     var result = scenarioRepo.Insert(scenario);
     return result;
 }
 /// <summary>
 /// This method will take a Scenario as input and will create a Controller object for that Scenario.
 /// </summary>
 /// <param name="scenario"></param>
 public Controller(Scenario scenario)
 {
     setUpController(scenario);
 }
 public bool Update(Scenario scenario)
 {
     return(pm.Merge <Scenario>(scenario));
 }
示例#46
0
 public OptimizationParameterSet Optimize(Scenario scenario, OptimizationUniverse universe = null)
 {
     return(this.optimizer?.Optimize(scenario));
 }
 private void AddLineDirective(CodeStatementCollection statements, Scenario scenario)
 {
     AddLineDirective(statements, scenario.FilePosition);
 }
示例#48
0
 private void DeleteScenario(Scenario scenario)
 {
     _repository.Delete(scenario);
     Scenarios.Remove(scenario);
 }
        private void SetupTestMethod(TestClassGenerationContext generationContext, CodeMemberMethod testMethod, Scenario scenario, Tags additionalTags, bool rowTest = false)
        {
            testMethod.Attributes = MemberAttributes.Public;
            testMethod.Name       = string.Format(TEST_NAME_FORMAT, scenario.Title.ToIdentifier());

            if (rowTest)
            {
                testGeneratorProvider.SetRowTest(generationContext, testMethod, scenario.Title);
            }
            else
            {
                testGeneratorProvider.SetTestMethod(generationContext, testMethod, scenario.Title);
            }

            if (scenario.Tags != null)
            {
                SetCategoriesFromTags(generationContext, testMethod, scenario.Tags);
            }
            if (additionalTags != null)
            {
                SetCategoriesFromTags(generationContext, testMethod, additionalTags);
            }
        }
示例#50
0
 private void ExportScenario(Scenario scenario)
 {
     _scenarioFileManager.Save(scenario);
 }
        private void GenerateTestBody(TestClassGenerationContext generationContext, Scenario scenario, CodeMemberMethod testMethod, CodeExpression additionalTagsExpression = null, ParameterSubstitution paramToIdentifier = null)
        {
            //call test setup
            //ScenarioInfo scenarioInfo = new ScenarioInfo("xxxx", tags...);
            CodeExpression tagsExpression;

            if (additionalTagsExpression == null)
            {
                tagsExpression = GetStringArrayExpression(scenario.Tags);
            }
            else if (scenario.Tags == null)
            {
                tagsExpression = additionalTagsExpression;
            }
            else
            {
                // merge tags list
                // var tags = tags1
                // if (tags2 != null)
                //   tags = Enumerable.ToArray(Enumerable.Concat(tags1, tags1));
                testMethod.Statements.Add(
                    new CodeVariableDeclarationStatement(typeof(string[]), "__tags", GetStringArrayExpression(scenario.Tags)));
                tagsExpression = new CodeVariableReferenceExpression("__tags");
                testMethod.Statements.Add(
                    new CodeConditionStatement(
                        new CodeBinaryOperatorExpression(
                            additionalTagsExpression,
                            CodeBinaryOperatorType.IdentityInequality,
                            new CodePrimitiveExpression(null)),
                        new CodeAssignStatement(
                            tagsExpression,
                            new CodeMethodInvokeExpression(
                                new CodeTypeReferenceExpression(typeof(Enumerable)),
                                "ToArray",
                                new CodeMethodInvokeExpression(
                                    new CodeTypeReferenceExpression(typeof(Enumerable)),
                                    "Concat",
                                    tagsExpression,
                                    additionalTagsExpression)))));
            }
            testMethod.Statements.Add(
                new CodeVariableDeclarationStatement(typeof(ScenarioInfo), "scenarioInfo",
                                                     new CodeObjectCreateExpression(typeof(ScenarioInfo),
                                                                                    new CodePrimitiveExpression(scenario.Title),
                                                                                    tagsExpression)));

            AddLineDirective(testMethod.Statements, scenario);
            testMethod.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeThisReferenceExpression(),
                    generationContext.ScenarioInitializeMethod.Name,
                    new CodeVariableReferenceExpression("scenarioInfo")));

            if (HasFeatureBackground(generationContext.Feature))
            {
                AddLineDirective(testMethod.Statements, generationContext.Feature.Background);
                testMethod.Statements.Add(
                    new CodeMethodInvokeExpression(
                        new CodeThisReferenceExpression(),
                        generationContext.FeatureBackgroundMethod.Name));
            }

            foreach (var scenarioStep in scenario.Steps)
            {
                GenerateStep(testMethod, scenarioStep, paramToIdentifier);
            }

            AddLineDirectiveHidden(testMethod.Statements);

            // call scenario cleanup
            testMethod.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeThisReferenceExpression(),
                    generationContext.ScenarioCleanupMethod.Name));
        }
示例#52
0
 public virtual void DictDeserialize(IDictionary <string, object> docu, Scenario scenario = Scenario.Database)
 {
     this.UnsafeDictDeserialize(docu);
 }
        private void GenerateTest(TestClassGenerationContext generationContext, Scenario scenario)
        {
            CodeMemberMethod testMethod = CreateTestMethod(generationContext, scenario, null);

            GenerateTestBody(generationContext, scenario, testMethod);
        }
示例#54
0
 public BackgroundEvent(Scenario scenario, Action <GherkinEvent> invokeEvent)
     : base(invokeEvent)
 {
     Scenario = scenario;
 }
示例#55
0
 public void CopySingleFileWithTransform()
 => Scenario
 .Given(I.start_with_a_clean_directory)
 .When(() => I.copy("foo.txt").with_a_doubled_filename())
 .Then(() => the.resulting_set_should_be("foofoo.txt"));
示例#56
0
 public ScenarioEvent(Scenario scenario, Action <GherkinEvent> invokeEvent)
     : base(invokeEvent)
 {
     Scenario = scenario;
 }
示例#57
0
 protected StockFlowMapBase6(Scenario scenario) : base(scenario)
 {
 }
示例#58
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                Console.WriteLine("Usage: Unpacker <path/to/sora> <output/path>");
                return;
            }

            try
            {
                var entries = DirProcessor.BuildEntries(args[0]);

                foreach (var pair in entries)
                {
                    Console.WriteLine("Processing '{0}'", pair.Key);

                    foreach (var entry in pair.Value)
                    {
                        if (entry.CompressedSize == 0 || entry.DecompressedSize == 0)
                        {
                            continue;
                        }

                        if (!entry.Name.EndsWith("_SN"))
                        {
                            continue;
                        }

/*						if (!entry.Name.StartsWith("T0310"))
 *                                              {
 *                                                      continue;
 *                                              }*/

                        Console.WriteLine("Processing script '{0}'", entry.Name);

                        try
                        {
                            byte[] bytes = new byte[entry.CompressedSize];
                            using (var stream = File.OpenRead(pair.Key))
                            {
                                stream.Seek(entry.Offset, SeekOrigin.Begin);
                                stream.Read(bytes, 0, bytes.Length);
                            }

                            bytes = FalcomDecompressor.Decompress(bytes);

                            var output = string.Empty;
                            using (var stream = new MemoryStream(bytes))
                            {
                                var scenario = Scenario.FromFCStream(stream);
                                output = scenario.ToString();
                            }

                            var fileName = Path.Combine(args[1], Path.ChangeExtension(entry.Name, "txt"));
                            File.WriteAllText(fileName, output);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#59
0
 public abstract void Assert(Scenario scenario, ScenarioAssertionException ex);
示例#60
0
 public void FileCopyWithOverwriteAlways()
 => Scenario
 .Given(I.start_with_a_clean_directory)
 .When(() => I.use_overwrite_mode(Overwrite.Always).to_copy_from(@"bar\baz.txt").to("sub"))
 .Then(() => the.content_of(@"bar\baz.txt").should_be_the_text("bar baz"))
 .And(() => the.content_of(@"sub\baz.txt").should_be_the_text("bar baz"));