コード例 #1
0
 public void Setup()
 {
     if (!testPath.EndsWith(@"\"))
     {
         testPath = testPath + @"\";
     }
     testRepo = new EntertainMeRepository();
 }
コード例 #2
0
        public void CreateNonExistingDB()
        {
            var repo = new EntertainMeRepository(testPath, testDBName);

            Assert.True(File.Exists(testPath + testDBName));
            var profile = repo.GetEMProfileByName("New_User");

            Assert.AreEqual("New_User", profile.UserName);
            repo.Dispose();
            if (File.Exists(testPath + testDBName))
            {
                File.Delete(testPath + testDBName);
            }
            if (Directory.Exists(testPath))
            {
                Directory.Delete(testPath, true);
            }
        }
コード例 #3
0
        private void mnuFileNew_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "EntertainMe file (*.db) | *.db";
            saveFileDialog.InitialDirectory = EntertainMe.Infrastructure.EMConstants.EntertainMePath;
            saveFileDialog.OverwritePrompt  = true;
            if (saveFileDialog.ShowDialog() == true)
            {
                string fullName = saveFileDialog.FileName;
                // Close current database
                if (EMRepository != null)
                {
                    EMRepository.Dispose();
                }
                string name = Path.GetFileName(fullName);
                string path = Path.GetDirectoryName(fullName);
                // If there is a database already , delete it
                if (File.Exists(fullName))
                {
                    string oldFile    = path + @"\" + name;
                    string oldLogFile = path +
                                        @"\" +
                                        name.Replace(Path.GetExtension(name), "") +
                                        "-log" +
                                        Path.GetExtension(name);
                    if (File.Exists(oldFile))
                    {
                        File.Delete(oldFile);
                    }
                    if (File.Exists(oldLogFile))
                    {
                        File.Delete(oldLogFile);
                    }
                }

                EMRepository = new EntertainMeRepository(path, name);
            }
        }
コード例 #4
0
 public void TearDown()
 {
     testRepo = null;
 }