Created
July 19, 2016 09:44
-
-
Save nickchampion/54fe02ce54b4c7315ef87d678b4fb94c to your computer and use it in GitHub Desktop.
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
using System; | |
using NUnit.Framework; | |
using Raven.Abstractions.Replication; | |
using Raven.Client; | |
using Raven.Client.Document; | |
namespace Marketplace.Tests.Unit | |
{ | |
[TestFixture] | |
public class RavenFailingTest | |
{ | |
[Test] | |
public void CanLoadAndSaveUser() | |
{ | |
var store = GetStore(); | |
var id = Guid.NewGuid().ToString(); | |
using (var session = store.OpenSession(new OpenSessionOptions | |
{ | |
Database = "Marketplace", | |
ForceReadFromMaster = true | |
})) | |
{ | |
session.Store(new TestUser | |
{ | |
Id = id, | |
FirstName = "Nick", | |
LastName = "Test", | |
Email = "test@email.com" | |
}); | |
session.SaveChanges(); | |
} | |
using (var session = store.OpenSession(new OpenSessionOptions | |
{ | |
Database = "Marketplace", | |
ForceReadFromMaster = true | |
})) | |
{ | |
session.Advanced.UseOptimisticConcurrency = true; | |
var user = session.Load<TestUser>(id); | |
user.LastName = Guid.NewGuid().ToString(); | |
session.SaveChanges(); | |
} | |
store.Dispose(); | |
} | |
private IDocumentStore GetStore() | |
{ | |
var store = new DocumentStore | |
{ | |
Url = "", | |
ApiKey = null, | |
ResourceManagerId = Guid.NewGuid(), | |
EnlistInDistributedTransactions = false, | |
Conventions = | |
{ | |
IndexAndTransformerReplicationMode = IndexAndTransformerReplicationMode.Indexes | IndexAndTransformerReplicationMode.Transformers, | |
FailoverBehavior = FailoverBehavior.ReadFromAllWriteToLeaderWithFailovers | |
} | |
}; | |
store.Initialize(); | |
return store; | |
} | |
} | |
public class TestUser | |
{ | |
public string Id { get; set; } | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string Email { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment