public void NestedSequence()
        {
            const string Expected =
                @"<try range=""IL_0000 (10)"">
  <try.block>
    <seq range=""IL_0000 (8)"">
      <il range=""IL_0000 (2)"" />
      <try range=""IL_0002 (4)"">
        <try.block>
          <il range=""IL_0002 (2)"" />
        </try.block>
        <handler type=""Clause"" exception=""02000010"">
          <il range=""IL_0004 (2)"" />
        </handler>
      </try>
      <il range=""IL_0006 (2)"" />
    </seq>
  </try.block>
  <handler type=""Finally"">
    <il range=""IL_0008 (2)"" />
  </handler>
</try>";

            var handlers = new[]
            {
                new ExceptionHandler(ExceptionHandlingClauseOptions.Clause, new ILRange(2, 2), new ILRange(4, 2), 0x02000010),
                new ExceptionHandler(ExceptionHandlingClauseOptions.Finally, new ILRange(0, 8), new ILRange(8, 2), 0),
            };

            var section = SectionFactory.Create(new ILRange(0, 10), handlers);

            Assert.That(Format(section), Is.EqualTo(Expected));
        }
Ejemplo n.º 2
0
        static BaseSection?BuildSections(MethodData data)
        {
            var         ilRange  = InstructionsRange(data.Instructions);
            BaseSection?sections = null;

            foreach (var dataSection in data.DataSections)
            {
                if (dataSection.ExceptionHandlers.Length > 0)
                {
                    if (sections != null)
                    {
                        return(null);
                    }

                    try
                    {
                        sections = SectionFactory.Create(ilRange, dataSection.ExceptionHandlers);
                    }
                    catch (CannotGenerateSectionException)
                    {
                        return(null);
                    }
                }
            }

            return(sections);
        }
        private void InitElements()
        {
            var codedUI = SectionFactory.InitializeSection <CodedUISection>();
            var qXs     = SectionFactory.InitializeSection <QXsSection>();
            var staging = SectionFactory.InitializeSection <StagingSection>();

            ToolStripMenuItem toolStripMenuItem13 = new ToolStripMenuItem();
            ToolStripMenuItem toolStripMenuItem14 = new ToolStripMenuItem();

            Items.AddRange(codedUI);
            Items.AddRange(qXs);
            Items.AddRange(staging);

            if (MainWindow.PathToAppConfig == string.Empty)
            {
                foreach (ToolStripItem item in Items)
                {
                    item.Enabled = false;
                }
            }

            toolStripMenuItem13.Text   = "Options";
            toolStripMenuItem13.Click += EventHandlers.OpenOptionsWindow;

            toolStripMenuItem14.Text   = "Exit";
            toolStripMenuItem14.Click += EventHandlers.ExitApplication;
            Items.AddRange(new ToolStripItem[] { toolStripMenuItem13, toolStripMenuItem14 });
        }
        public void Sequence()
        {
            const string Expected =
                @"<seq range=""IL_0000 (22)"">
  <il range=""IL_0000 (2)"" />
  <try range=""IL_0002 (8)"">
    <try.block>
      <il range=""IL_0002 (4)"" />
    </try.block>
    <handler type=""Clause"" exception=""02000010"">
      <il range=""IL_0006 (4)"" />
    </handler>
  </try>
  <il range=""IL_000A (2)"" />
  <try range=""IL_000C (8)"">
    <try.block>
      <il range=""IL_000C (4)"" />
    </try.block>
    <handler type=""Clause"" exception=""02000010"">
      <il range=""IL_0010 (4)"" />
    </handler>
  </try>
  <il range=""IL_0014 (2)"" />
</seq>";

            var handlers = new[]
            {
                new ExceptionHandler(ExceptionHandlingClauseOptions.Clause, new ILRange(2, 4), new ILRange(6, 4), 0x02000010),
                new ExceptionHandler(ExceptionHandlingClauseOptions.Clause, new ILRange(12, 4), new ILRange(16, 4), 0x02000010),
            };

            var section = SectionFactory.Create(new ILRange(0, 22), handlers);

            Assert.That(Format(section), Is.EqualTo(Expected));
        }
        public void OverlappingTry()
        {
            const string Expected =
                @"<try range=""IL_0000 (10)"">
  <try.block>
    <il range=""IL_0000 (2)"" />
  </try.block>
  <handler type=""Clause"" exception=""02000011"">
    <il range=""IL_0002 (4)"" />
  </handler>
  <handler type=""Clause"" exception=""02000012"">
    <il range=""IL_0006 (4)"" />
  </handler>
</try>";

            var handlers = new[]
            {
                new ExceptionHandler(ExceptionHandlingClauseOptions.Clause, new ILRange(0, 2), new ILRange(2, 4), 0x02000011),
                new ExceptionHandler(ExceptionHandlingClauseOptions.Clause, new ILRange(0, 2), new ILRange(6, 4), 0x02000012),
            };

            var section = SectionFactory.Create(new ILRange(0, 10), handlers);

            Assert.That(Format(section), Is.EqualTo(Expected));
        }
        public void Create_Always_WillCreateASectionWithName()
        {
            var sectionFactory = new SectionFactory(new QuestionFactory());

            Base section = sectionFactory.Create(new StringReader("Section 0"));

            Assert.AreEqual("Section", section.Name);
        }
Ejemplo n.º 7
0
        public void Create_Always_WillCreateASectionWithName()
        {
            var  sectionFactory = new SectionFactory(new QuestionFactory());
            Base section        = sectionFactory.Create(new StringReader("Sec1 0"));

            Assert.IsInstanceOf(typeof(Section), section);
            Assert.AreEqual("Sec1", section.Name);
        }
Ejemplo n.º 8
0
        public void CreateSectionTests()
        {
            var s = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters);

            Assert.AreEqual("[", s.Tokens[0]);
            Assert.AreEqual("foo", s.Tokens[1]);
            Assert.AreEqual("]", s.Tokens[2]);
        }
Ejemplo n.º 9
0
        public void CreateSection_Always_WillReturnASectionWithName()
        {
            var sectionFactory = new SectionFactory();

            ISection section = sectionFactory.CreateSection(new StringReader("Section 0"));

            Assert.AreEqual("Section", section.Name);
        }
Ejemplo n.º 10
0
        public void SetUp()
        {
            Mock <IQuestionFactory> mockQuestion = new Mock <IQuestionFactory>();

            _sectionFactory = new SectionFactory {
                QuestionFactory = mockQuestion.Object
            };
        }
Ejemplo n.º 11
0
        public static void Main()
        {
            bugsnagClient = new Bugsnag.Client(new Bugsnag.Configuration
            {
                ApiKey     = "fa43381b116de659fcf1cfda14884d98",
                AppVersion = Application.ProductVersion,
                AutoNotify = false
            });

            // install custom handler for fatal exceptions
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            // route UI thread exceptions to the fatal exception handler
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);

            RemoveOldVersionSettings();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var mainForm              = new MainForm();
            var tileCache             = new BitmapCache();
            var dialogService         = new DialogService(mainForm);
            var featureService        = new FeatureService();
            var sectionsService       = new SectionService();
            var sectionFactory        = new SectionFactory(tileCache);
            var sectionBitmapService  = new SectionBitmapService(sectionFactory);
            var mapModelFactory       = new MapModelFactory(tileCache);
            var mapLoadingService     = new MapLoadingService(sectionFactory, mapModelFactory);
            var imageImportingService = new ImageImportService(tileCache);
            var model = new CoreModel();

            // Unsure if I should get the SectionViews to register themselves, or pass the dispatcher the SectionViews as params
            mainForm.SectionView.SetModel(new SectionViewViewModel(sectionsService));
            mainForm.FeatureView.SetModel(new FeatureViewViewModel(featureService));

            var dispatcher = new Dispatcher(
                model,
                dialogService,
                sectionsService,
                sectionBitmapService,
                featureService,
                mapLoadingService,
                imageImportingService,
                tileCache,
                mainForm);

            mainForm.SetModel(new MainFormViewModel(model, dispatcher));

            mainForm.MapViewPanel.SetModel(new MapViewViewModel(model, dispatcher, featureService));

            var minimapForm = new MinimapForm();

            minimapForm.Owner = mainForm;
            minimapForm.SetModel(new MinimapFormViewModel(model, dispatcher));

            Application.Run(mainForm);
        }
Ejemplo n.º 12
0
        public void Create_WhenSectionHasQuestions_WillPopulateTheListOfItems()
        {
            var  mockQuestion   = new Mock <IQuestionFactory>();
            var  sectionFactory = new SectionFactory(mockQuestion.Object);
            Base section        = sectionFactory.Create(new StringReader(@"Sec1 1
FT Name"));

            Assert.AreEqual(1, section.Items.Count);
        }
Ejemplo n.º 13
0
        public void Create_WhenSectionContainsQuestions_WillSetTheListOfItems()
        {
            var sectionFactory = new SectionFactory(new QuestionFactory());

            var section = sectionFactory.Create(new StringReader(@"Sec1 1
Q1 Name"));

            Assert.AreEqual(1, section.Items.Count);
        }
        public void Method_scenario_behaviour()
        {
            var sectionFactory = new SectionFactory();

            Base section = sectionFactory.Create(new StringReader(@"Sec1 1
SC Sex 2 Female Male"));

            Assert.AreEqual(1, section.Items.Count);
        }
Ejemplo n.º 15
0
        public void AddsProperty()
        {
            var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters);
            var section  = new IniSection(sentence, null);

            Assert.AreEqual("foo", section.Name);
            Assert.IsFalse(section.Comments.Any());
            Assert.IsFalse(section.Properties.Any());
        }
Ejemplo n.º 16
0
        public void CreateSection_WillReturnASectionWithName()
        {
            SectionFactory sectionFactory = new SectionFactory();

            var section = sectionFactory.CreateSection(new StringReader("Sec1 0"));

            Assert.IsInstanceOf(typeof(Section), section);
            Assert.AreEqual("Sec1", section.Name);
        }
        public void Create_WhenSectionHAsQuestions_WillReturnASectionWithAListOfQuestions()
        {
            var sectionFactory = new SectionFactory();

            var section = sectionFactory.Create(new StringReader(@"Section 1
Q1 Name"));

            // Assert.AreEqual(1, section.);
        }
Ejemplo n.º 18
0
        public void Empty()
        {
            const string Expected =
                @"<il range=""IL_0000 (10)"" />";

            var section = SectionFactory.Create(new ILRange(0, 10), Array.Empty <ExceptionHandler>());

            Assert.That(Format(section), Is.EqualTo(Expected));
        }
        public void CreateSection_Always_WillReturnASectionWithName()
        {
            var mock           = new Mock <IQuestionFactory>();
            var sectionFactory = new SectionFactory(mock.Object);

            Base item = sectionFactory.Create(new StringReader("Section 0"));

            Assert.IsInstanceOf(typeof(Section), item);
        }
        public void Create_WhenItemHasChildren_WillSetTheLIstOfItems()
        {
            var sectionFactory = new SectionFactory(new QuestionFactory());

            Base section = sectionFactory.Create(new StringReader(@"Section 1
Q1 Name"));

            Assert.AreEqual(1, section.Items.Count);
        }
 public void SetUp()
 {
     _mock = new Mock <IQuestionFactory> {
         DefaultValue = DefaultValue.Mock
     };
     _sectionFactory = new SectionFactory {
         QuestionFactory = _mock.Object
     };
 }
Ejemplo n.º 22
0
        public void CreateSection_Always_WillCreateASectionWithName()
        {
            SectionFactory sectionFactory = new SectionFactory();

            var section = sectionFactory.CreateSection(new StringReader("Section 0"));

            Assert.IsInstanceOf(typeof(ISection), section);
            Assert.AreEqual("Section", section.Name);
        }
        public void CreateSection_Always_WillCreateASection()
        {
            SectionFactory sectionFactory = new SectionFactory();

            var section = sectionFactory.CreateSection(new StringReader(@"Sec1 1
Q1 FT Numele"));

            Assert.IsInstanceOf(typeof(ISection), section);
            Assert.That("Sec1", Is.EqualTo(section.Name));
        }
        public void Create_WhenSectionHasQuestions_WillSetTheListOfItems()
        {
            var mockQuestionFactory = new Mock <IQuestionFactory>();
            var sectionFactory      = new SectionFactory(mockQuestionFactory.Object);

            Base section = sectionFactory.Create(new StringReader(@"Sec1 2
FT Nume
FT Prenume"));

            Assert.AreEqual(2, section.Items.Count);
        }
Ejemplo n.º 25
0
        public void DisallowsDuplicateProperties()
        {
            var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters);
            var section  = new IniSection(sentence, new IniFile(sentence, new IniSettings
            {
                DuplicatePropertyHandling = DuplicatePropertyHandling.Disallow
            }));

            section.AddProperty("bar", "baz");
            section.AddProperty("bar", "qux");
        }
Ejemplo n.º 26
0
        public void CreateSection_WhenContainsQuestions_WillSetTheListOfQuestions()
        {
            var mockQuestionFactory = new Mock <IQuestionFactory>();
            var sectionFactory      = new SectionFactory {
                QuestionFactory = mockQuestionFactory.Object
            };

            ISection section = sectionFactory.CreateSection(new StringReader(@"Section 1
Q1 Name"));

            Assert.AreEqual(1, section.Questions.Count);
        }
Ejemplo n.º 27
0
        public void AddPropertyTests()
        {
            var sentence = SectionFactory.CreateSection("foo", Grammar.DefaultDelimiters);
            var section  = new IniSection(sentence, new IniFile());

            section.AddComment("baz");
            section.AddComment("qux");

            Assert.IsTrue(section.Comments.Count() == 2);
            Assert.IsTrue(section.Comments.ElementAt(0) == "baz");
            Assert.IsTrue(section.Comments.ElementAt(1) == "qux");
        }
        public void CreateSection_WillCreateASectionWithQuestions()
        {
            Mock <IQuestionFactory> mockQuestionFactory = new Mock <IQuestionFactory>();
            SectionFactory          sectionFactory      = new SectionFactory {
                QuestionFactory = mockQuestionFactory.Object
            };

            var section = sectionFactory.CreateSection(new StringReader(@"Sec1 1
Q1 Name"));

            Assert.AreEqual(1, section.Questions.Count);
        }
Ejemplo n.º 29
0
        public void CreateSection_WhenContainsQuestions_WillSetTheQuestionsList()
        {
            Mock <IQuestionFactory> mockQuestionFactory = new Mock <IQuestionFactory>();
            SectionFactory          sectionFactory      = new SectionFactory {
                QuestionFactory = mockQuestionFactory.Object
            };

            var section = sectionFactory.CreateSection(new StringReader(@"Sec1 1
Q1 Name"), 2);

            Assert.AreEqual(1, section.Questions.Count);
        }
Ejemplo n.º 30
0
        public void CreateSection_WhenHasQuestions_WillSetTheLIstOfQuestions()
        {
            Mock <IQuestionFactory> mock           = new Mock <IQuestionFactory>();
            SectionFactory          sectionFactory = new SectionFactory {
                QuestionFactory = mock.Object
            };

            var section = sectionFactory.CreateSection(new StringReader(@"Section 2
Q1 NAme
Q2 Age"));

            Assert.AreEqual(2, section.Questions.Count);
        }