Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only executing test when we are admin
- Loading branch information
Showing
1 changed file
with
69 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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; | |||
} | |||
} | |||
} | |||
} |