public static void Run <T>(Resource resource, IErrorReporter reporter, ICodeGeneratorEnv environment)
            where T : ICodeGenerator, new()
        {
            using (var reader = resource.CreateTextReader())
            {
                var reporterWrapper = new ReporterWrapper(reporter);

                var generator = new T();
                generator.Load(reader, reporterWrapper, environment);

                if (!reporterWrapper.HasError)
                {
                    using (TextWriter writer = new StringWriter())
                    {
                        generator.Write(writer);
                    }

                    foreach (var file in generator.AdditionalFiles)
                    {
                        using (Stream stream = new MemoryStream())
                        {
                            file.GenerateFileContent(stream);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public void LoginButtonClick()
        {
            SolutionBrowser._browser.Sync();

            ReporterWrapper.ReporterContext("Click on Login Button", () =>
            {
                lp.LoginButton.Click();
                // Add Button Click Validation
            });
        }
Beispiel #3
0
        public void PasswordSet()
        {
            SolutionBrowser._browser.Sync();

            ReporterWrapper.ReporterContext("Set Password credentials", () =>
            {
                lp.PasswordEditField.SetValue(user.Pwd);
                SolutionBrowser._browser.Sync();
                VerifyWrapper.IsMatch(lp.PasswordEditField.Value, user.Pwd, "Set Password", "Check the PasswordEditField to make its value matches the one extracted from the Excel File.", SolutionBrowser.GetSnapshot());
            });
        }
Beispiel #4
0
        public void UsernameSet()
        {
            SolutionBrowser._browser.Sync();

            ReporterWrapper.ReporterContext("Set Username credentials", () =>
            {
                lp.UsernameEditField.SetValue(user.Email);
                SolutionBrowser._browser.Sync();
                VerifyWrapper.IsMatch(lp.UsernameEditField.Value, user.Email, "Set Username", "Check the UsernameEditField to make sure its value is the username extracted from the Excel file", SolutionBrowser.GetSnapshot());
            });
        }
Beispiel #5
0
        public void GetUserInfos()
        {
            user = excel.GetUserFromName(FILE_PATH, SITE, FIRSTNAME, LASTNAME);

            ReporterWrapper.ReporterContext("Get user information", () =>
            {
                // When the Password verification fails, the Email verification also fails, even though it's not empty.
                VerifyWrapper.IsNotNullOrEmpty(user.Email, "Check if user contains email address", "Check if an email address was found in the excel file", null);
                VerifyWrapper.IsNotNullOrEmpty(user.Pwd, "Check if user contains password", "Check if a password was found in the excel file", null);
            });
        }
Beispiel #6
0
        public void LoginLinkClick()
        {
            SolutionBrowser._browser.Sync();

            ReporterWrapper.ReporterContext("Click on login link", () =>
            {
                lp.LoginLink.Click();
                SolutionBrowser._browser.Sync();

                VerifyWrapper.IsMatch(SolutionBrowser._browser.URL, "login", "Navigate to login page", "Click on link to navigate to the login page", SolutionBrowser.GetSnapshot());
            });
        }
Beispiel #7
0
        public void TestFixtureSetUp()
        {
            ReporterWrapper.ReporterContext("Launch browser", () =>
            {
                if (SolutionBrowser._browser == null)
                {
                    SolutionBrowser.LaunchBrowser();
                }

                VerifyWrapper.IsNotNull(SolutionBrowser._browser, "Check Browser", "Open and launch browser if it hasn't been already done.");
            });
        }
        public void AddWarning()
        {
            var reporter = new Mock <IErrorReporter>(MockBehavior.Strict);

            var wrapper = new ReporterWrapper(reporter.Object);

            Assert.That(wrapper.HasError, Is.EqualTo(false));

            reporter.Setup(x => x.AddWarning(1, 2, 3, 4, "Text")).Verifiable();
            wrapper.AddWarning(1, 2, 3, 4, "Text");
            Assert.That(wrapper.HasError, Is.EqualTo(false));
            reporter.Verify();
        }
Beispiel #9
0
        public bool Load(TextReader reader, IErrorReporter reporter, ICodeGeneratorEnv environment)
        {
            var wrapper = new ReporterWrapper(reporter);

            _loadStart       = null;
            _parseDone       = null;
            _calculationDone = null;
            _tableDone       = null;

            _loadStart = DateTime.Now;

            var parser = new ConfigParser(wrapper);
            var config = parser.Parse(new ConfigScanner(reader.ReadToEnd()));

            _parseDone = DateTime.Now;

            if (wrapper.HasError)
            {
                _config = null;
                return(false);
            }

            SyntaxTreeDecorator.Decorate(config, wrapper);
            _calculationDone = DateTime.Now;

            if (wrapper.HasError)
            {
                _config = null;
                return(false);
            }

            _data      = TableGenerator.GenerateTables(config);
            _tableDone = DateTime.Now;

            if (!config.Manager.SuppressTableEmbedding)
            {
                config.TableResourceName = environment.GetResourceName(ParserTableFile.Suffix);
            }

            _config = config;
            return(true);
        }
Beispiel #10
0
        public bool Load(TextReader reader, IErrorReporter reporter, ICodeGeneratorEnv environment)
        {
            var wrapper = new ReporterWrapper(reporter);

            _loadStart       = null;
            _parseDone       = null;
            _calculationDone = null;
            _writeStart      = null;
            _writeDone       = null;

            _loadStart = DateTime.Now;

            var parser = new ConfigParser(wrapper);
            var config = parser.Parse(new ConfigScanner(reader.ReadToEnd()));

            _parseDone = DateTime.Now;

            if (wrapper.HasError)
            {
                return(false);
            }

            config.TableResourceNameFormat = environment.GetResourceName(".{0}.table");

            SyntaxTreeDecorator.Decorate(config, wrapper);

            _calculationDone = DateTime.Now;

            if (wrapper.HasError)
            {
                _config = null;
                return(false);
            }
            else
            {
                _config = config;
                return(true);
            }
        }
        public void ReadFromDevice()
        {
            ReporterWrapper reporter = new ReporterWrapper(m_Reporter);

            reporter.Completed += (sender, e) =>
            {
                bool   allValuesFailed;
                bool   allValuesSucceeded;
                string messageString = Settings.GetCommunicationFailureString(m_Settings.Values, 20, out allValuesFailed, out allValuesSucceeded);

                ParentForm.ShowIncompatableFirmwareWarning(m_Settings);

                if (allValuesSucceeded == true)
                {
                    return;
                }

                if (allValuesFailed == true)
                {
                    messageString = "Failed to read all settings.";
                }
                else
                {
                    messageString = "Failed to read the following settings:" + messageString;
                }

                ParentForm.InvokeShowError(messageString);
            };

            try
            {
                m_Settings.ReadAync(reporter, Options.Timeout, Options.MaximumNumberOfRetries);
            }
            catch
            {
            }
        }
        public void WriteToDevice()
        {
            ReporterWrapper reporter = new ReporterWrapper(m_Reporter);

            reporter.Completed += (sender, e) =>
            {
                bool   allValuesFailed;
                bool   allValuesSucceeded;
                string messageString = Settings.GetCommunicationFailureString(m_Settings.Values, 20, out allValuesFailed, out allValuesSucceeded);

                if (allValuesSucceeded == true)
                {
                    return;
                }

                if (allValuesFailed == true)
                {
                    messageString = "Failed to confirm write of all settings.";
                }
                else
                {
                    messageString = "Failed to confirm write of following settings:" + messageString;
                }

                ParentForm.InvokeShowError(messageString);
            };

            try
            {
                m_Settings.WriteAync(reporter, Options.Timeout, Options.MaximumNumberOfRetries);
                m_Settings.Connection?.SendCommand(Command.Apply);
            }
            catch
            {
            }
        }
 public static void AddReporterRef(string pRefId, ReporterWrapper wrapper)
 {
     Reporters[pRefId] = wrapper;
 }