Exemplo n.º 1
0
        public IActionResult About()
        {
            TestMetric testMetric = new TestMetric();
            var        jobs       = testMetric.MainFunc();

            ViewData["Message"] = "Your about page.";
            ViewData["Jobs"]    = jobs;
            return(View());
        }
        public TestVerdict PerformanceTest()
        {
            try
            {
                Setup();

                this.PauseExecution();

                // #1 - Relying on sdet to start and stop timer.
                using (TestMetric testMetric = new TestMetric("797686977979", "Test of thread sleep"))
                {
                    testMetric.Start();

                    Thread.Sleep(30000);

                    testMetric.Stop();  // This is technically not necessary as Dispose in this construct stops the running timer.

                    testMetric.StateArgs.Add("This is an important runtime comment.");
                }

                this.ContinueExecution();

                //// #2 - Calling with constructor automatically starting timer.
                //using (TestMetric testMetric = new TestMetric(this, true, "Test of thread sleep"))
                //{
                //    // Do whatever is being performance tested (e.g., rendering a window).
                //    Thread.Sleep(5000);
                //}

                //// #3 - Another way //
                //TestMetric testMetric2 = new TestMetric(this, "Test of another thread sleep.");

                //testMetric2.Start();

                //Thread.Sleep(5000);

                //testMetric2.Stop(); // This is actually not necessary if Dispose is called (it stops a running timer).

                //testMetric2.Dispose();

                TestVerdict = TestVerdict.Pass;
                TestMessage = "This is the initial test message.";
            }
            catch (Exception e)
            {
                TestMessage += e.ToString();
                TestVerdict  = TestVerdict.Error;
            }
            finally
            {
                Teardown();
            }

            return(TestVerdict);
        }
Exemplo n.º 3
0
        public void BuildResult_ReturnsResultWithScore(TestMetric metric, int scoreFrom, int scoreTo)
        {
            // Given
            WidaTestBuilder builder = new WidaTestBuilder(new TestAssigner(), new BogusFabricator());
            TestSession     session = new TestSession();
            TestSection     section = new TestSection()
            {
                Metric = metric
            };
            Student  student = new Student();
            DateTime date    = DateTime.Now;
            // When
            TestResult result = builder.BuildResult(section, date);

            // Then
            Assert.NotNull(result.Score);
            Assert.InRange(Int32.Parse(result.Score), scoreFrom, scoreTo);
        }
Exemplo n.º 4
0
        public void Should_NotBeEqual_WhenCustomMetricEqualsSessionMetric()
        {
            var     sessionMetric      = new SessionMetric(NodeMetric.Counters.AuthenticationErrors.Name);
            IMetric sessionMetricBase  = sessionMetric;
            IMetric sessionMetricBase2 = sessionMetric;

            var testMetric = new TestMetric {
                Name = NodeMetric.Counters.AuthenticationErrors.Name
            };
            IMetric testMetricBase  = testMetric;
            IMetric testMetricBase2 = testMetric;

            Assert.IsFalse(testMetric.Equals(sessionMetric));
            Assert.IsFalse(sessionMetric.Equals(testMetric));

            Assert.IsFalse(testMetric.Equals(sessionMetricBase));
            Assert.IsFalse(sessionMetricBase.Equals(testMetric));

            Assert.IsFalse(testMetric.Equals(sessionMetricBase2));
            Assert.IsFalse(sessionMetricBase2.Equals(testMetric));

            Assert.IsFalse(testMetricBase.Equals(sessionMetric));
            Assert.IsFalse(sessionMetric.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase.Equals(sessionMetricBase));
            Assert.IsFalse(sessionMetricBase.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase.Equals(sessionMetricBase2));
            Assert.IsFalse(sessionMetricBase2.Equals(testMetricBase));

            Assert.IsFalse(testMetricBase2.Equals(sessionMetric));
            Assert.IsFalse(sessionMetric.Equals(testMetricBase2));

            Assert.IsFalse(testMetricBase2.Equals(sessionMetricBase));
            Assert.IsFalse(sessionMetricBase.Equals(testMetricBase2));

            Assert.IsFalse(testMetricBase2.Equals(sessionMetricBase2));
            Assert.IsFalse(sessionMetricBase2.Equals(testMetricBase2));
        }
Exemplo n.º 5
0
 int GetScore(TestMetric metric) =>
 metric switch
 {
Exemplo n.º 6
0
 TestSection GetSection(string name, TestMetric metric) => new TestSection
 {
     Name   = name,
     Metric = metric
 };