Browse files

Make sure to delete the data directory after the test.

Rename class name.
  • Loading branch information...
1 parent 861c9e8 commit 5a6d467abdebfa9938e304e369901875832b6663 @fitzchak committed Apr 4, 2012
View
2 Raven.Tests/Bugs/ConflictsWithIIS.cs
@@ -7,7 +7,7 @@
namespace Raven.Tests.Bugs
{
- public class ConflictsWithIIS : IISExpressTestClient
+ public class ConflictsWithIIS : IisExpressTestClient
{
public class DeviceStatusRecord
{
View
2 Raven.Tests/Bugs/Identifiers/SpecialCharactersOnIIS.cs
@@ -23,7 +23,7 @@ public class SpecialCharactersOnIIS : WithNLog
[InlineData("SHA1-UdVhzPmv0o+wUez+Jirt0OFBcUY=")]
public void Can_load_entity(string entityId)
{
- using (var testContext = new IISExpressTestClient())
+ using (var testContext = new IisExpressTestClient())
{
using (var store = testContext.NewDocumentStore())
{
View
2 Raven.Tests/Bugs/MetadataBugs.cs
@@ -9,7 +9,7 @@
namespace Raven.Tests.Bugs
{
- public class MetadataBugs : IISExpressTestClient
+ public class MetadataBugs : IisExpressTestClient
{
public class DeviceStatusRecord
{
View
44 Raven.Tests/IISDeploymentUtil.cs
@@ -1,44 +0,0 @@
-using System;
-using System.IO;
-using Raven.Client;
-using Raven.Database.Extensions;
-
-namespace Raven.Tests
-{
- public class IISDeploymentUtil
- {
- protected const string WebDirectory = @".\RavenIISTestWeb\";
-
- public static string DeployWebProjectToTestDirectory()
- {
- var fullPath = Path.GetFullPath(WebDirectory);
- if (Directory.Exists(fullPath))
- {
- IOExtensions.DeleteDirectory(fullPath);
- }
-
- IOExtensions.CopyDirectory(GetRavenWebSource(), WebDirectory);
-
- return fullPath;
- }
-
- private static string GetRavenWebSource()
- {
- foreach (var path in new[] { @".\..\..\..\Raven.Web", @".\_PublishedWebsites\Raven.Web" })
- {
- var fullPath = Path.GetFullPath(path);
-
- if (Directory.Exists(fullPath) && File.Exists(Path.Combine(fullPath, "web.config")))
- {
- var combine = Path.Combine(fullPath, "bin");
- if (!Directory.Exists(combine) || Directory.GetFiles(combine, "Raven.Web.dll").Length == 0)
- throw new Exception("Raven.Web\\bin at " + fullPath + " was nonexistent or empty, you need to build Raven.Web.");
-
- return fullPath;
- }
- }
-
- throw new FileNotFoundException("Could not find source directory for Raven.Web");
- }
- }
-}
View
52 Raven.Tests/IISExpressTestClient.cs
@@ -1,38 +1,66 @@
using System;
+using System.IO;
using Raven.Client;
using Raven.Client.Document;
+using Raven.Database.Extensions;
using Raven.Tests.Util;
namespace Raven.Tests
{
- public class IISExpressTestClient : IDisposable
+ public class IisExpressTestClient : IDisposable
{
+ private const string WebDirectory = @".\RavenIISTestWeb\";
public static int Port = 8084;
+ private IISExpressDriver iisExpress;
- private IISExpressDriver _iisExpress;
+ private static string DeployWebProjectToTestDirectory()
+ {
+ IOExtensions.DeleteDirectory(Path.GetFullPath(WebDirectory));
- public IDocumentStore NewDocumentStore()
+ IOExtensions.CopyDirectory(GetRavenWebSource(), WebDirectory);
+
+ return Path.GetFullPath(WebDirectory);
+ }
+
+ private static string GetRavenWebSource()
{
- if (_iisExpress == null)
+ foreach (var path in new[] { @".\..\..\..\Raven.Web", @".\_PublishedWebsites\Raven.Web" })
{
- _iisExpress = new IISExpressDriver();
+ var fullPath = Path.GetFullPath(path);
+
+ if (Directory.Exists(fullPath) && File.Exists(Path.Combine(fullPath, "web.config")))
+ {
+ var combine = Path.Combine(fullPath, "bin");
+ if (!Directory.Exists(combine) || Directory.GetFiles(combine, "Raven.Web.dll").Length == 0)
+ throw new Exception("Raven.Web\\bin at " + fullPath + " was nonexistent or empty, you need to build Raven.Web.");
- _iisExpress.Start(IISDeploymentUtil.DeployWebProjectToTestDirectory(), 8084);
+ return fullPath;
+ }
}
- return new DocumentStore()
+ throw new FileNotFoundException("Could not find source directory for Raven.Web");
+ }
+
+ public IDocumentStore NewDocumentStore()
+ {
+ if (iisExpress == null)
{
- Url = _iisExpress.Url
- }.Initialize();
+ iisExpress = new IISExpressDriver();
+ iisExpress.Start(DeployWebProjectToTestDirectory(), 8084);
+ }
+
+ return new DocumentStore {Url = iisExpress.Url}.Initialize();
}
public void Dispose()
{
- if (_iisExpress != null)
+ if (iisExpress != null)
{
- _iisExpress.Dispose();
- _iisExpress = null;
+ iisExpress.Dispose();
+ iisExpress = null;
}
+
+ IOExtensions.DeleteDirectory(Path.GetFullPath(WebDirectory));
}
}
}
View
66 Raven.Tests/MailingList/IisQueryLengthIssues.cs
@@ -1,39 +1,39 @@
-using System;
-using Raven.Tests.Bugs.Identifiers;
-using System.Linq;
-using Xunit;
-
-namespace Raven.Tests.MailingList
-{
- public class IisQueryLengthIssues : IISExpressTestClient
+using System;
+using Raven.Tests.Bugs.Identifiers;
+using System.Linq;
+using Xunit;
+
+namespace Raven.Tests.MailingList
+{
+ public class IisQueryLengthIssues : IisExpressTestClient
{
private readonly string[] errorOptions = new[]
{
"Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxQueryString setting in the applicationhost.config or web.config file.",
"The length of the query string for this request exceeds the configured maxQueryStringLength value"
- };
-
- [IISExpressInstalledFact]
- public void ShouldFailGracefully()
- {
- using (var store = NewDocumentStore())
- {
- var name = new string('x', 0x1000);
- var exception = Assert.Throws<InvalidOperationException>(() => store.OpenSession().Query<User>().Where(u => u.FirstName == name).ToList());
-
- Assert.True(errorOptions.Any(s => exception.Message.Contains(s)));
- }
- }
-
- [IISExpressInstalledFact]
- public void ShouldFailGracefully_StaticIndex()
- {
- using (var store = NewDocumentStore())
- {
- var name = new string('x', 0x1000);
- var exception = Assert.Throws<InvalidOperationException>(() => store.OpenSession().Query<User>("test").Where(u => u.FirstName == name).ToList());
- Assert.True(errorOptions.Any(s => exception.Message.Contains(s)));
- }
- }
- }
+ };
+
+ [IISExpressInstalledFact]
+ public void ShouldFailGracefully()
+ {
+ using (var store = NewDocumentStore())
+ {
+ var name = new string('x', 0x1000);
+ var exception = Assert.Throws<InvalidOperationException>(() => store.OpenSession().Query<User>().Where(u => u.FirstName == name).ToList());
+
+ Assert.True(errorOptions.Any(s => exception.Message.Contains(s)));
+ }
+ }
+
+ [IISExpressInstalledFact]
+ public void ShouldFailGracefully_StaticIndex()
+ {
+ using (var store = NewDocumentStore())
+ {
+ var name = new string('x', 0x1000);
+ var exception = Assert.Throws<InvalidOperationException>(() => store.OpenSession().Query<User>("test").Where(u => u.FirstName == name).ToList());
+ Assert.True(errorOptions.Any(s => exception.Message.Contains(s)));
+ }
+ }
+ }
}
View
1 Raven.Tests/Raven.Tests.csproj
@@ -515,7 +515,6 @@
<Compile Include="Document\TotalCountServerTest.cs" />
<Compile Include="Document\WhenUsingMultipleUnshardedServers.cs" />
<Compile Include="Document\ZoneCountResult.cs" />
- <Compile Include="IISDeploymentUtil.cs" />
<Compile Include="IISExpressTestClient.cs" />
<Compile Include="Bugs\IndexDefinitions.cs" />
<Compile Include="Indexes\AnalyzerResolution.cs" />

0 comments on commit 5a6d467

Please sign in to comment.