Beispiel #1
0
        public void UpdateResult(TestResultObject result)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <TestResultObject>(UpdateStart), result);
            }
            else
            {
                if (result == null)
                {
                    labelResult.Text       = "ERROR";
                    richTextBoxResult.Text = "ERROR";
                    return;
                }

                if (result.Status == TestResultStatus.Pass)
                {
                    labelResult.Text      = Pass;
                    labelResult.BackColor = Color.Lime;
                }
                else
                {
                    labelResult.Text      = Fail;
                    labelResult.BackColor = Color.Red;
                }

                richTextBoxResult.Text = result.ToString();
            }
        }
Beispiel #2
0
        private void UpdateDgv(TestResultObject result)
        {
            if (result == null)
            {
                return;
            }

            InitDgv();

            var values = result.CsvValues().Split(',');

            if (dgvDetails.Rows.Count != values.Length)
            {
                dgvDetails.Rows.Clear();
                dgvDetails.Rows.Add(values.Length);
                var headers = result.CsvHeaders().Split(',');
                for (var i = 0; i < values.Length && i < headers.Length; i++)
                {
                    dgvDetails.Rows[i].Cells[0].Value = headers[i];
                    dgvDetails.Rows[i].Cells[1].Value = values[i];
                }
            }
            else
            {
                for (var i = 0; i < values.Length; i++)
                {
                    dgvDetails.Rows[i].Cells[1].Value = values[i];
                }
            }

            dgvDetails.Update();
        }
Beispiel #3
0
        public void UpdateResult(TestResultObject result)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <TestResultObject>(UpdateResult), result);
            }
            else
            {
                if (result == null)
                {
                    labelResult.Text = "NULL";
                    return;
                }

                UpdateDgv(result);

                if (result.Status == TestResultStatus.Pass)
                {
                    labelResult.Text      = Pass;
                    labelResult.BackColor = Color.Lime;
                }
                else
                {
                    labelResult.Text      = Fail;
                    labelResult.BackColor = Color.Red;
                }


                statisticsControl.InsertResult(result);
            }
        }
Beispiel #4
0
        public void ConfigHandler_Poco_FromRedirectBody_ShouldCallIntoParserWithXmlValue()
        {
            InAnotherCastleHandler handler = new InAnotherCastleHandler();

            object expectedObject = new TestResultObject();

            string expectedXml          = "<TestPassedIn></TestPassedIn>";
            int    expectedCachDuration = 919191;


            //Setup mock components used by handler
            var type = typeof(MockProvider);

            SetConfigurationSection(type.AssemblyQualifiedName);
            InAnotherCastleHandler.RefreshConfiguration();
            //Allow the cache function to execute the get section functionality within the handler
            var mockProvider = (MockProvider)InAnotherCastleHandler.Configuration.ServiceProvider;
            var testCach     = (MockProvider.MockCache)(mockProvider).GetConfigCacheValue;

            testCach.ExecuteCache = true;
            var mockStorage = (MockProvider.MockStorage)mockProvider.GetStorageValue;

            mockStorage.GetConfigurationSectionFunc = (n, s) =>
            {
                Assert.Fail("There should be no reason for the handler to use the storage function if the POCO body is set in the parser.");
                return(null);
            };

            string resultingXml = null;

            handler.Parser = new TestParser()
            {
                ParseRedirectDetailsValue = (xml) => new MockRedirectIdentifier()
                {
                    Type = typeof(TestResultObject).AssemblyQualifiedName,
                    Mode = Mode.Poco,
                    CacheDurationInMinutes = expectedCachDuration,
                    //Note poco body is populated so it should be used instead of a db call
                    PocoBody = new PocoBody()
                    {
                        Value = expectedXml
                    }
                },
                POCOConfigSectionParseValue = (xml, t) =>
                {
                    resultingXml = xml;
                    return(expectedObject);
                }
            };

            XmlDocument document = new XmlDocument();

            document.LoadXml("<TestSectionName></TestSectionName>");
            var resultingObject = handler.Create(null, null, document.FirstChild);

            Assert.AreEqual(resultingObject, expectedObject, "Object returned should be the expected as it has been mocked in the pipeline");
            Assert.AreEqual(resultingXml, expectedXml, "XML is expected to be based on the mock");
        }
Beispiel #5
0
        public void UpdateStart(TestResultObject result)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <TestResultObject>(UpdateStart), result);
            }
            else
            {
                labelResult.Text      = ProcessString;
                labelResult.BackColor = Color.Gold;

                UpdateDgv(result);
            }
        }
Beispiel #6
0
        public void UpdateDetails(TestResultObject result)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <TestResultObject>(UpdateDetails), result);
            }
            else
            {
                if (result == null)
                {
                    labelResult.Text = "NULL";
                    return;
                }

                UpdateDgv(result);
            }
        }
        public void InsertResult(TestResultObject result)
        {
            if (result.Status == TestResultStatus.Pass)
            {
                UpdateStatDict(Pass);
            }
            else
            {
                UpdateStatDict(Fail);
                if (!string.IsNullOrEmpty(result.Error))
                {
                    UpdateStatDict(result.Error);
                }
            }

            UpdateStatDict(Total);

            OnUpdateStat();
        }
        public void AppendResult(TestResultObject result, bool isUpdateColor = false)
        {
            int c   = dgvDetails.ColumnCount;
            var col = dgvDetails.Columns.Add($"Result{c}", $"Result{c}");

            dgvDetails.Columns[col].SortMode     = DataGridViewColumnSortMode.NotSortable;
            dgvDetails.Columns[col].ReadOnly     = true;
            dgvDetails.Columns[col].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

            if (result == null)
            {
                return;
            }

            var values = result.CsvValues().Split(',');

            if (dgvDetails.Rows.Count < values.Length)
            {
                dgvDetails.Rows.Add(values.Length - dgvDetails.RowCount + 1);
                var headers = result.CsvHeaders().Split(',');
                for (var i = 0; i < values.Length && i < headers.Length; i++)
                {
                    dgvDetails.Rows[i + 1].Cells[0].Value   = headers[i];
                    dgvDetails.Rows[i + 1].Cells[col].Value = values[i];
                }
            }
            else
            {
                for (var i = 0; i < values.Length; i++)
                {
                    dgvDetails.Rows[i + 1].Cells[col].Value = values[i];
                }
            }

            dgvDetails.Rows[0].Cells[col].Value = result.Status.ToString();
            if (isUpdateColor)
            {
                dgvDetails.Rows[0].Cells[col].Style.BackColor = result.Status == TestResultStatus.Pass ? Color.Lime : Color.Red;
            }

            dgvDetails.Update();
        }
        public void UpdateResult(TestResultObject result)
        {
            if (result == null)
            {
                labelResult.Text      = "ERROR";
                labelResult.BackColor = Color.LightGray;
                return;
            }

            if (result.Status == TestResultStatus.Pass)
            {
                labelResult.Text      = Pass;
                labelResult.BackColor = Color.Lime;
            }
            else
            {
                labelResult.Text      = Fail;
                labelResult.BackColor = Color.Red;
            }
        }
Beispiel #10
0
        public void UpdateStart(TestResultObject result)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <TestResultObject>(UpdateStart), result);
            }
            else
            {
                if (result == null)
                {
                    labelResult.Text       = "ERROR";
                    richTextBoxResult.Text = "ERROR";
                    return;
                }

                labelResult.Text      = ProcessString;
                labelResult.BackColor = Color.Gold;

                richTextBoxResult.Clear();
                richTextBoxResult.Text = result.ToString();
            }
        }
 public void UpdateStart(TestResultObject result)
 {
     labelResult.Text      = ProcessString;
     labelResult.BackColor = Color.Gold;
 }
Beispiel #12
0
        public void ConfigHandler_Poco_FromDataStore_ShouldCallIntoParserWithXmlValue()
        {
            InAnotherCastleHandler handler = new InAnotherCastleHandler();

            object expectedObject = new TestResultObject();

            string             expectedName               = "TestName";
            string             expectedSystemName         = "SystemName";
            string             expectedXml                = "<TestPassedIn></TestPassedIn>";
            int                expectedCachDuration       = 919191;
            ConfigurationValue expectedConfigurationValue = new ConfigurationValue()
            {
                XML = expectedXml
            };

            //Setup mock components used by handler
            var type = typeof(MockProvider);

            SetConfigurationSection(type.AssemblyQualifiedName);
            InAnotherCastleHandler.RefreshConfiguration();
            //Allow the cache function to execute the get section functionality within the handler
            var mockProvider = (MockProvider)InAnotherCastleHandler.Configuration.ServiceProvider;
            var testCach     = (MockProvider.MockCache)(mockProvider).GetConfigCacheValue;

            testCach.ExecuteCache = true;
            var    mockStorage = (MockProvider.MockStorage)mockProvider.GetStorageValue;
            string resultingName = null, resultingSystemName = null, resultingXml = null;

            mockStorage.GetConfigurationSectionFunc = (n, s) =>
            {
                resultingName       = n;
                resultingSystemName = s;
                return(expectedConfigurationValue);
            };
            handler.Parser = new TestParser()
            {
                ParseRedirectDetailsValue = (xml) => new MockRedirectIdentifier()
                {
                    Type                   = typeof(TestResultObject).AssemblyQualifiedName,
                    Name                   = expectedName,
                    SystemName             = expectedSystemName,
                    Mode                   = Mode.Poco,
                    CacheDurationInMinutes = expectedCachDuration
                },
                POCOConfigSectionParseValue = (xml, t) =>
                {
                    resultingXml = xml;
                    return(expectedObject);
                }
            };

            XmlDocument document = new XmlDocument();

            document.LoadXml("<Test></Test>");
            var resultingObject = handler.Create(null, null, document.FirstChild);

            Assert.AreEqual(resultingObject, expectedObject, "Object returned should be the expected as it has been mocked in the pipeline");
            Assert.AreEqual(resultingName, expectedName, "Name is expected based on mock");
            Assert.AreEqual(resultingSystemName, expectedSystemName, "System Name is expected based on mock");
            Assert.AreEqual(resultingXml, expectedXml, "XML is expected to be based on the mock");
        }