コード例 #1
0
        public void SaveStatisticsTest()
        {
            var test = new Test {
                Name = "First test"
            };
            var uits = new UIStatistics {
                NumberOfCorrect = 2, PercentOfCorrect = 50, TestName = "First test", TimeInMinutes = 1
            };

            var mockObj = TestsMethodsTests.Create(new List <TestStatistic>());
            var mockT   = TestsMethodsTests.Create(new List <Test> {
                test
            });

            var mockContext = new Mock <Test2DBContainer>();

            mockContext.Setup(m => m.TestStatistics).Returns(mockObj.Object);
            mockContext.Setup(m => m.Tests).Returns(mockT.Object);

            var service = new Service(mockContext.Object);

            service.SaveStatistics(uits);

            //mockObj.Verify(m => m.Add(It.IsAny<TestStatistic>()), Times.Once);
            mockContext.Verify(m => m.SaveChanges(), Times.Once);
        }
コード例 #2
0
        private void Finishbutton_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            lbTimer.BackColor = Color.Transparent;
            DisableUI(false);

            var stat = new UIStatistics();

            foreach (var item in splitContainer4.Panel2.Controls)
            {
                var s = item as GroupBox;
                if (s != null)
                {
                    var res     = 0;
                    var correct = 0;
                    foreach (Control btn in s.Controls)
                    {
                        var tag = (UIAnswer)btn.Tag;
                        if (tag.IsCorrect)
                        {
                            correct++;
                        }
                        var w = btn as RadioButton;
                        if (w != null)
                        {
                            if (w.Checked && tag.IsCorrect)
                            {
                                res++;
                            }
                        }

                        var w1 = btn as CheckBox;
                        if (w1 != null)
                        {
                            if (w1.Checked && tag.IsCorrect)
                            {
                                res++;
                            }
                        }
                    }
                    if (res == correct)
                    {
                        stat.NumberOfCorrect++;
                    }
                }
            }
            stat.TestName         = SelectedTest.name;
            stat.TimeInMinutes    = secondsCounter;
            stat.PercentOfCorrect = stat.NumberOfCorrect * 100 / (int)splitContainer4.Panel2.Tag;
            service.SaveStatistics(stat);
        }
コード例 #3
0
    void BtnStatisticsOnClick(PointerEventData eventData, UI_Event ev)
    {
        UIStatistics ui_statistics = MenuManager.instance.CreateMenu <UIStatistics>();

        ui_statistics.OpenScreen();
    }