Beispiel #1
0
    public static void Create()
    {
        
        try{
        
            using (var db = new DataBase())
            {
                if(!db.DatabaseExists() || AppSettings.GetVersion() !="v1.0")
                {              
                   
                    db.DeleteDatabase();
                    //db.CreateDatabase();
                    //createfordebug();
                    CopyDataBase();
                    
                    AppSettings.SetSound(false);
                    AppSettings.SetPro(false);
                    AppSettings.SetVersion("v1.0");
                    
                }
            
           
            } 
        }
        catch(Exception ex)
        {

        }
    }
        public void IdLevelWitheMaxCountElementsTest()
        {
            DataBase.Create();
            using (var b = new DataBase())
            {
                b.DeleteDatabase();
                b.CreateDatabase();
                b.Lessons.InsertOnSubmit(new Lesson());
                b.Lessons.InsertOnSubmit(new Lesson());
                b.Lessons.InsertOnSubmit(new Lesson());
                b.Lessons.InsertOnSubmit(new Lesson());
                b.Lessons.InsertOnSubmit(new Lesson());
                b.SubmitChanges();
                var temp = b.Lessons;
                Word w;
                int i;

                foreach (var t in temp)
                {

                    i = 2;
                    w = new Word() { Level = i++};
                    t.AttachWord(w);
                    b.Words.InsertOnSubmit(w);
                    w = new Word() { Level = i++ };
                    t.AttachWord(w);
                    b.Words.InsertOnSubmit(w);
                    w = new Word() { Level = i };
                    t.AttachWord(w);
                    b.Words.InsertOnSubmit(w);
                    w = new Word() { Level = i++ };
                    t.AttachWord(w);
                    b.Words.InsertOnSubmit(w);
                    w = new Word() { Level = i++ };
                    t.AttachWord(w);
                    b.Words.InsertOnSubmit(w);
                }
                b.SubmitChanges();
                Assert.AreEqual(4, WordRepository.LevelWitheMaxCountElements());

            }
        }