public void Initialize()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways <ChineseTrainerContext>());

            var testSetupContext = new ChineseTrainerContext(TestDatabaseName);

            Guard <Dictionary>(testSetupContext);
            Guard <DictionaryEntry>(testSetupContext);
            Guard <Translation>(testSetupContext);
            Guard <Highscore>(testSetupContext);
            Guard <Answer>(testSetupContext);

            var dictionary1 = CreateDictionary("1");

            testSetupContext.Add(dictionary1);

            var dictionary2 = CreateDictionary("2");

            testSetupContext.Add(dictionary2);

            var highscore = CreateHighscore(dictionary1);

            testSetupContext.Add(highscore);

            _questionResultId = highscore.QuestionResult.Id;
            foreach (var answer in highscore.QuestionResult.Answers)
            {
                testSetupContext.Add(answer);
            }

            testSetupContext.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            Database.SetInitializer(new DropCreateDatabaseAlways <ChineseTrainerContext>());

            var objectUnderTest = new ChineseTrainerContext(TestDatabaseName);

            Guard <Dictionary>(objectUnderTest);
            Guard <DictionaryEntry>(objectUnderTest);
            Guard <Translation>(objectUnderTest);
            Guard <Highscore>(objectUnderTest);
            Guard <User>(objectUnderTest);

            var dictionary1 = CreateDictionary("1");

            objectUnderTest.Add(typeof(Dictionary), dictionary1);

            var dictionary2 = CreateDictionary("2");

            objectUnderTest.Add(typeof(Dictionary), dictionary2);

            var highscore = CreateHighscore(dictionary1);

            objectUnderTest.Add(typeof(Highscore), highscore);

            objectUnderTest.SaveChanges();
        }
Ejemplo n.º 3
0
 public void AddQuestionResult(QuestionResult questionResult)
 {
     ChineseTrainerContext.Add(questionResult);
     ChineseTrainerContext.SaveChanges();
 }
Ejemplo n.º 4
0
 public void AddHighscore(Highscore highscore)
 {
     ChineseTrainerContext.Add(highscore);
     ChineseTrainerContext.SaveChanges();
 }
Ejemplo n.º 5
0
 public void AddDictionaryEntry(DictionaryEntry dictionaryEntry)
 {
     ChineseTrainerContext.Add(dictionaryEntry);
     ChineseTrainerContext.SaveChanges();
 }
Ejemplo n.º 6
0
 public void AddAnswer(Answer answer)
 {
     ChineseTrainerContext.Add(answer);
     ChineseTrainerContext.SaveChanges();
 }