Exemple #1
0
        public async Task CreateUniquePersonalTestResult()
        {
            using (SelfAssessmentDbContext context = new SelfAssessmentDbContext())
            {
                Account    account    = context.Accounts.Where(a => a.User.Username == "test2").FirstOrDefault();
                Test       test       = context.Tests.Where(t => t.TestName == "TestName2").FirstOrDefault();
                TestResult testResult = new TestResult()
                {
                    Mark = 10
                };
                await testResultService.CreatePersonalTestResult(account.Id, test.TestName, testResult);

                TestResult retrievedTestResult = context.TestResults
                                                 .Include(t => t.Account)
                                                 .ThenInclude(t => t.User)
                                                 .Where(t => t.Mark == 10)
                                                 .Where(t => t.Test.TestName == "TestName2").FirstOrDefault();
                Assert.AreEqual(10, retrievedTestResult.Mark);
                Assert.AreEqual("test2", retrievedTestResult.Account.User.Username);
            }
        }