Skip to content

Commit

Permalink
Only executing test when we are admin
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Aug 2, 2011
1 parent e7b731b commit 0cbed7f
Showing 1 changed file with 69 additions and 39 deletions.
108 changes: 69 additions & 39 deletions Raven.Tests/Bugs/Identifiers/SpecialCharactersOnIIS.cs
@@ -1,45 +1,75 @@
using System; // //-----------------------------------------------------------------------
// // <copyright company="Hibernating Rhinos LTD">
// // Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// // </copyright>
// //-----------------------------------------------------------------------
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Security.Principal;
using System.Text;
using Raven.Client;
using Raven.Client.Document;
using Xunit; using Xunit;
using Xunit.Extensions; using Xunit.Extensions;
using Xunit.Sdk;


namespace Raven.Tests.Bugs.Identifiers namespace Raven.Tests.Bugs.Identifiers
{ {
public class SpecialCharactersOnIIS : WithNLog public class SpecialCharactersOnIIS : WithNLog
{ {
public class Entity [AdminOnlyTheory]
{ [InlineData("foo")]
public string Id { get; set; } [InlineData("SHA1-UdVhzPmv0o+wUez+Jirt0OFBcUY=")]
} public void Can_load_entity(string entityId)

{
[Theory] var testContext = new IISClientTest();
[InlineData("foo")]
[InlineData("SHA1-UdVhzPmv0o+wUez+Jirt0OFBcUY=")] using (var store = testContext.GetDocumentStore())
public void Can_load_entity(string entityId) {
{ store.Initialize();
var testContext = new IISClientTest();

using (var session = store.OpenSession())
using(var store = testContext.GetDocumentStore()) {
{ var entity = new Entity {Id = entityId};
store.Initialize(); session.Store(entity);

session.SaveChanges();
using (var session = store.OpenSession()) }
{
var entity = new Entity() { Id = entityId }; using (var session = store.OpenSession())
session.Store(entity); {
session.SaveChanges(); var entity1 = session.Load<object>(entityId);
} Assert.NotNull(entity1);

}
using (var session = store.OpenSession()) }
{ }
var entity1 = session.Load<object>(entityId);
Assert.NotNull(entity1); #region Nested type: Entity
}
} public class Entity
} {
} public string Id { get; set; }
} }

#endregion
}

public class AdminOnlyTheory : TheoryAttribute
{
protected override IEnumerable<ITestCommand> EnumerateTestCommands(IMethodInfo method)
{
var windowsIdentity = WindowsIdentity.GetCurrent();
if (windowsIdentity != null)
{
if (new WindowsPrincipal(windowsIdentity).IsInRole(WindowsBuiltInRole.Administrator) == false)
{
var displayName = method.TypeName + "." + method.Name;
yield return
new SkipCommand(method, displayName,
"Could not execute " + displayName +" because it requires Admin privileges");
yield break;
}
}

foreach (var command in base.EnumerateTestCommands(method))
{
yield return command;
}
}
}
}

0 comments on commit 0cbed7f

Please sign in to comment.