Exemplo n.º 1
0
        public void testIsRegisteredInDatabase()
        {
            LINQDatabase mockDatabase = mocks.Stub <LINQDatabase>();

            User zarakavaUse = new User();

            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                mockDatabase.getUser("Zarakava");
                LastCall.Return(zarakavaUse);
                mockDatabase.getUser("NULLMAN");
                LastCall.Return(null);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.isRegistered("Zarakava"));
            Assert.IsFalse(UserRegistration.isRegistered("NULLMAN"));
        }
Exemplo n.º 2
0
        public void testRegisteredInDatabase()
        {
            LINQDatabase mockDatabase = mocks.Stub <LINQDatabase>();

            User zarakavaUse = new User();

            zarakavaUse.setName("Zarakava");
            zarakavaUse.setPass("Testing");

            using (mocks.Record())
            {
                // The mock will return "Whale Rider" when the call is made with 24
                //mockDatabase.registerUser(zarakavaUse);
                //LastCall.Return(true);
                // mockDatabase.registerUser(null);
                // LastCall.Return(false);
            }

            UserRegistration.setDatabase(mockDatabase);
            Assert.IsTrue(UserRegistration.register(zarakavaUse));
            Assert.IsFalse(UserRegistration.register(null));
        }
Exemplo n.º 3
0
        public static void ClearDatabase(LINQDatabase db)
        {
            // Pending Mail Table
            var mrows = from row in db.PendingMail
                       select row;
            foreach (var row in mrows)
                db.PendingMail.DeleteOnSubmit(row);
            db.SubmitChanges();

            // Users Table
            var urows = from row in db.Users
                       select row;
            foreach (var row in urows)
                db.Users.DeleteOnSubmit(row);
            db.SubmitChanges();

            // Tags Table
            var trows = from row in db.Tags
                        select row;
            foreach (var row in trows)
                db.Tags.DeleteOnSubmit(row);
            db.SubmitChanges();

            // Files Table
            var frows = from row in db.Files
                        select row;
            foreach (var row in frows)
                db.Files.DeleteOnSubmit(row);
            db.SubmitChanges();

            // TagName Table
            var tnrows = from row in db.Files
                        select row;
            foreach (var row in tnrows)
                db.Files.DeleteOnSubmit(row);
            db.SubmitChanges();
        }
Exemplo n.º 4
0
 public static LINQDatabase EmptyDatabase()
 {
     LINQDatabase db = new LINQDatabase();
     ClearDatabase(db);
     return db;
 }
Exemplo n.º 5
0
        public static LINQDatabase PopulatedDatabase()
        {
            LINQDatabase db = new LINQDatabase();
            ClearDatabase(db);

            CaesFile music = new CaesFile();
            music.Path = musicFile;
            db.Files.InsertOnSubmit(music);

            CaesFile sound = new CaesFile();
            sound.Path = soundFile;
            db.Files.InsertOnSubmit(sound);

            CaesFile anime = new CaesFile();
            anime.Path = animeFile;
            db.Files.InsertOnSubmit(anime);

            CaesFile video = new CaesFile();
            video.Path = videoFile;
            db.Files.InsertOnSubmit(video);

            db.SubmitChanges();

            // Music File
            Tag m1 = new Tag();
            m1.FilePath = musicFile;
            m1.TagName = "audio";
            db.Tags.InsertOnSubmit(m1);

            Tag m2 = new Tag();
            m2.FilePath = musicFile;
            m2.TagName = "mp3";
            db.Tags.InsertOnSubmit(m2);

            // Sound File
            Tag s1 = new Tag();
            s1.FilePath = soundFile;
            s1.TagName = "audio";
            db.Tags.InsertOnSubmit(s1);

            Tag s2 = new Tag();
            s2.FilePath = soundFile;
            s2.TagName = "wav";
            db.Tags.InsertOnSubmit(s2);

            // Anime File
            Tag a1 = new Tag();
            a1.FilePath = animeFile;
            a1.TagName = "anime";
            db.Tags.InsertOnSubmit(a1);

            Tag a2 = new Tag();
            a2.FilePath = animeFile;
            a2.TagName = "video";
            db.Tags.InsertOnSubmit(a2);

            Tag a3 = new Tag();
            a3.FilePath = animeFile;
            a3.TagName = "mkv";
            db.Tags.InsertOnSubmit(a3);

            // Video File
            Tag v1 = new Tag();
            v1.FilePath = videoFile;
            v1.TagName = "video";
            db.Tags.InsertOnSubmit(v1);

            Tag v2 = new Tag();
            v2.FilePath = videoFile;
            v2.TagName = "avi";
            db.Tags.InsertOnSubmit(v2);

            db.SubmitChanges();

            return db;
        }
Exemplo n.º 6
0
 public static void setDatabase(LINQDatabase toSet)
 {
     database = toSet;
 }
Exemplo n.º 7
0
 public static void setDatabase(LINQDatabase toSet)
 {
     database = toSet;
 }