private static async Task <int> AddUser(IDocumentStore leaderStore, string email, string userId) { try { using (var session = leaderStore.OpenAsyncSession(new SessionOptions { TransactionMode = TransactionMode.ClusterWide })) { var user = new UniqueUser { Name = "Grisha", Email = email }; await session.StoreAsync(user, userId); session.Advanced.ClusterTransaction.CreateCompareExchangeValue(email, userId); await session.SaveChangesAsync(); } } catch (ConcurrencyException) { return(1); } return(0); }
public void InitializeTestSuite() { if (_IsInstanciated) { return; } Trace.WriteLine("////////////////////////////////////////////////////////////////////"); Trace.WriteLine(" INIT table mappings START"); Trace.WriteLine("////////////////////////////////////////////////////////////////////\n"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); UniqueUserManager.GetUser(Guid.NewGuid()); stopwatch.Stop(); Trace.WriteLine("Tablemappings initialization time: " + stopwatch.Elapsed.ToString()); stopwatch.Reset(); stopwatch.Start(); UniqueUserManager.GetUserPage(0, 10); stopwatch.Stop(); Trace.WriteLine("Stored Procedure initialization time: " + stopwatch.Elapsed.ToString()); DummyDataManager dtm = new DummyDataManager(System.Configuration.ConfigurationSettings.AppSettings["XmlDummyDataPath"]); Random random = new Random(); DummyUser dummy = dtm.GetDummy(); UniqueUser user = new UniqueUser() { AccountStatus = 0, City = dummy.City, DateOfBirth = dummy.DateOfBirth, Firstname = dummy.Firstname, IsNewletterSubscriber = (random.Next(0, 2) == 1), Lastname = dummy.Surname, Timezone = random.NextDouble() * 10 }; stopwatch.Reset(); stopwatch.Start(); BusinessObjectActionReport <UniqueUserActionStatus> report = UniqueUserManager.Create(user); report = UniqueUserManager.Delete(user); stopwatch.Stop(); Trace.WriteLine("Stored Procedure initialization time: " + stopwatch.Elapsed.ToString()); Trace.WriteLine("\n////////////////////////////////////////////////////////////////////"); Trace.WriteLine(" INIT table mappings END "); Trace.WriteLine("////////////////////////////////////////////////////////////////////\n\n\n"); Trace.WriteLine(" START TESTS "); Trace.WriteLine("////////////////////////////////////////////////////////////////////\n"); _IsInstanciated = true; }