Skip to content

Commit fa8341a

Browse files
committed
Reuse integration test project data in RootSite tests
1 parent dbfb518 commit fa8341a

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

Src/Common/RootSite/RootSiteTests/RealDataTestsBase.cs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,19 @@ namespace SIL.FieldWorks.Common.RootSites.RootSiteTests
1818
[TestFixture]
1919
public abstract class RealDataTestsBase
2020
{
21+
private const string ReusableProjectName = "integration_test_data";
22+
2123
protected FwNewLangProjectModel m_model;
2224
protected LcmCache Cache;
2325
protected string m_dbName;
26+
private string m_projectDirectory;
2427

2528
[SetUp]
2629
public virtual void TestSetup()
2730
{
28-
m_dbName = "RealDataTest_" + Guid.NewGuid().ToString("N");
29-
var dbPath = DbFilename(m_dbName);
30-
if (File.Exists(dbPath))
31-
File.Delete(dbPath);
31+
m_dbName = ReusableProjectName;
32+
m_projectDirectory = DbDirectory(m_dbName);
33+
DeleteProjectDirectory(m_projectDirectory);
3234

3335
// Init New Lang Project Model (headless)
3436
m_model = new FwNewLangProjectModel(true)
@@ -48,6 +50,7 @@ public virtual void TestSetup()
4850
m_model.Next(); // To Analysis WS Setup
4951
m_model.SetDefaultWs(new LanguageInfo { LanguageTag = "en", DesiredName = "English" });
5052
createdPath = m_model.CreateNewLangProj(new DummyProgressDlg(), threadHelper);
53+
m_projectDirectory = Path.GetDirectoryName(createdPath);
5154
}
5255

5356
// Load the cache from the newly created .fwdata file
@@ -98,16 +101,22 @@ public virtual void TestTearDown()
98101
Cache.Dispose();
99102
Cache = null;
100103
}
101-
var dbPath = DbFilename(m_dbName);
102-
if (File.Exists(dbPath))
103-
{
104-
try { File.Delete(dbPath); } catch { }
105-
}
104+
105+
DeleteProjectDirectory(m_projectDirectory);
106+
m_projectDirectory = null;
106107
}
107108

108-
protected string DbFilename(string name)
109+
protected string DbDirectory(string name)
109110
{
110-
return Path.Combine(Path.GetTempPath(), name + ".fwdata");
111+
return Path.Combine(FwDirectoryFinder.ProjectsDirectory, name);
112+
}
113+
114+
private static void DeleteProjectDirectory(string projectDirectory)
115+
{
116+
if (string.IsNullOrEmpty(projectDirectory) || !Directory.Exists(projectDirectory))
117+
return;
118+
119+
try { Directory.Delete(projectDirectory, true); } catch { }
111120
}
112121
}
113122
}

0 commit comments

Comments
 (0)