Exemplo n.º 1
0
        private Test GenerateTestFromTestSeries(TestSeries tests, int seriesNumber)
        {
            var test = new Test(string.Format("{0} {1}", tests.Name, seriesNumber), tests.Subject, tests.SubCategory,
                                seriesNumber, tests.MaximumPoints);

            return(test);
        }
Exemplo n.º 2
0
        private async void FuncToCall5(object context)
        {
            if (NewSeriesName == null || NewSeriesName == "")
            {
                MessageBox.Show("You must enter a series name.");
            }
            else
            {
                TestSeries checkTestSeries = Context.TestSeries.Where(t => t.TestSeriesName == NewSeriesName).FirstOrDefault();
                if (checkTestSeries == null)
                {
                    IDataService <TestSeries> service = new GenericDataService <TestSeries>();
                    await service.Create(new TestSeries()
                    {
                        TestSeriesName = NewSeriesName
                    });

                    _             = GetAllTestSeries();
                    NewSeriesName = null;
                }
                else
                {
                    MessageBox.Show("A test series by this name already exists.");
                }
            }
        }
Exemplo n.º 3
0
 public async Task InsertTestSeriesAsync(TestSeries tests)
 {
     for (var i = 0; i < tests.TestCount; i++)
     {
         var seriesNumber = i + 1;
         var test         = GenerateTestFromTestSeries(tests, seriesNumber);
         await InsertTestAsync(test);
     }
 }
Exemplo n.º 4
0
 public void InsertTestSeries(TestSeries tests)
 {
     for (var i = 0; i < tests.TestCount; i++)
     {
         var seriesNumber = i + 1;
         var test         = GenerateTestFromTestSeries(tests, seriesNumber);
         InsertTest(test);
     }
 }
 public async Task <List <TestResult> > GetPersonalTestResults(Account currentAccount, string selectedSeries)
 {
     using (SelfAssessmentDbContext context = new SelfAssessmentDbContext())
     {
         TestSeries series = context.TestSeries
                             .Where(s => s.TestSeriesName == selectedSeries).FirstOrDefault();
         return(await context.TestResults
                .Include(q => q.Test)
                .ThenInclude(qr => qr.TestSeries)
                .Where(r => r.Account.Id == currentAccount.Id)
                .Where(e => e.Test.TestSeries.Id == series.Id).ToListAsync());
     }
 }
Exemplo n.º 6
0
        public void ConvertSeriesProperties_ChartData_NameSetToSeries()
        {
            // Setup
            const string name          = "<Some name>";
            var          testConverter = new TestChartDataConverter();
            var          chartData     = new TestChartData(name);
            var          chartSeries   = new TestSeries();

            // Call
            testConverter.ConvertSeriesProperties(chartData, chartSeries);

            // Assert
            Assert.AreEqual(name, chartSeries.Title);
        }
Exemplo n.º 7
0
        public void ConvertSeriesProperties_DataNull_ThrowsArgumentNullException()
        {
            // Setup
            var testConverter = new TestChartDataConverter();
            var series        = new TestSeries();

            // Call
            TestDelegate test = () => testConverter.ConvertSeriesProperties(null, series);

            // Assert
            const string expectedMessage = "Null data cannot be converted into series data.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage);
        }
Exemplo n.º 8
0
        public async Task <int> AddTestAsync(int deviceId, int distance)
        {
            var test = new TestSeries
            {
                DeviceId  = deviceId,
                Distance  = distance,
                StartedAt = DateTimeOffset.UtcNow
            };

            _context.TestSeries.Add(test);

            await SaveChangesAsync();

            return(test.TestSeriesId);
        }
Exemplo n.º 9
0
        public void ConvertSeriesProperties_ChartData_IsVisibleSetToSeries(bool isVisible)
        {
            // Setup
            var testConverter = new TestChartDataConverter();
            var chartData     = new TestChartData("test data")
            {
                IsVisible = isVisible
            };
            var chartSeries = new TestSeries();

            // Call
            testConverter.ConvertSeriesProperties(chartData, chartSeries);

            // Assert
            Assert.AreEqual(isVisible, chartSeries.IsVisible);
        }
Exemplo n.º 10
0
        public RandomViewChartViewModel()
        {
            Rnd          = new Random();
            DpModel      = new DataPointModel();
            DpModels     = new ObservableCollection <DataPointModel>();
            TestSerie    = new TestSeries();
            TestSeriesOc = new ObservableCollection <TestSeries>
            {
                TestSeries.Create(SeriesTypeEnum.Line,
                                  new ObservableCollection <TestSeriesData>
                {
                    TestSeriesData.Create(1, 5, Rnd.Next(0, 100)),
                    TestSeriesData.Create(2, 10, 20),
                    TestSeriesData.Create(3, 15, Rnd.Next(0, 100)),
                    TestSeriesData.Create(4, 20, 35),
                    TestSeriesData.Create(5, 25, Rnd.Next(0, 100)),
                    TestSeriesData.Create(6, 30, Rnd.Next(0, 100)),
                    TestSeriesData.Create(7, 35, 65),
                    TestSeriesData.Create(8, 40, Rnd.Next(0, 100)),
                    TestSeriesData.Create(9, 45, Rnd.Next(0, 100)),
                    TestSeriesData.Create(10, 50, Rnd.Next(0, 100))
                }),
                TestSeries.Create(SeriesTypeEnum.Point,
                                  new ObservableCollection <TestSeriesData>
                {
                    TestSeriesData.Create(4, 20, 35)
                }),
                TestSeries.Create(SeriesTypeEnum.Point,
                                  new ObservableCollection <TestSeriesData>
                {
                    TestSeriesData.Create(7, 35, 65)
                })
            };


            TestSerieData    = new TestSeriesData();
            TestSeriesDataOc = new ObservableItemCollection <TestSeriesData>();

            ButtonCommand = new DelegateCommand(ButtonExecuted);
        }
Exemplo n.º 11
0
 private void NavToAddTestSeries(TestSeries testSeries)
 {
     _addEditTestSeriesViewModel.SetTestSeries(testSeries);
     CurrentViewModel = _addEditTestSeriesViewModel;
 }
Exemplo n.º 12
0
        public void Setup()
        {
            User user = new User()
            {
                Username       = "******",
                PasswordHashed = "test2",
                Email          = "*****@*****.**",
                DateJoined     = DateTime.Now
            };

            Account account = new Account()
            {
                User = user,
            };

            TestSeries testSeries = new TestSeries()
            {
                TestSeriesName = "TestTestSeries",
            };

            Test test = new Test()
            {
                TestSeries = testSeries,
                TestName   = "TestName"
            };


            Test secondTest = new Test()
            {
                TestSeries = testSeries,
                TestName   = "TestName2"
            };

            TestResult testResult = new TestResult()
            {
                Account = account,
                Mark    = 30,
                Test    = test
            };

            MainTopic mainTopic = new MainTopic()
            {
                Title = "MainTopic"
            };

            SubTopic subTopic = new SubTopic()
            {
                MainTopic = mainTopic,
                Title     = "SubTopic"
            };

            using (SelfAssessmentDbContext context = new SelfAssessmentDbContext())
            {
                context.Accounts.Add(account);
                context.TestSeries.Add(testSeries);
                context.MainTopics.Add(mainTopic);
                context.SubTopics.Add(subTopic);
                context.Tests.Add(test);
                context.Tests.Add(secondTest);
                context.TestResults.Add(testResult);
                context.SaveChanges();
            }
        }