forked from ravendb/ravendb
/
WhenUsingParallelAccessStrategy.cs
43 lines (40 loc) · 1.48 KB
/
WhenUsingParallelAccessStrategy.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//-----------------------------------------------------------------------
// <copyright file="WhenUsingParallelAccessStrategy.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using Raven.Client.Document;
using Raven.Client.Shard;
using Raven.Tests.Document;
using Xunit;
namespace Raven.Tests.Shard
{
public class WhenUsingParallelAccessStrategy : RemoteClientTest
{
[Fact]
public void NullResultIsNotAnException()
{
using(GetNewServer())
using (var shard1 = new DocumentStore { Url = "http://localhost:8079" }.Initialize())
using (var session = shard1.OpenSession())
{
var results = new ParallelShardAccessStrategy().Apply(new[] { shard1.DatabaseCommands }, new ShardRequestData(), (x, i) => (IList<Company>)null);
Assert.Equal(1, results.Length);
Assert.Null(results[0]);
}
}
[Fact]
public void ExecutionExceptionsAreRethrown()
{
using (GetNewServer())
using (var shard1 = new DocumentStore { Url = "http://localhost:8079" }.Initialize())
using (var session = shard1.OpenSession())
{
var parallelShardAccessStrategy = new ParallelShardAccessStrategy();
Assert.Throws<ApplicationException>(() => parallelShardAccessStrategy.Apply<object>(new[] {shard1.DatabaseCommands}, new ShardRequestData(), (x, i) => { throw new ApplicationException(); }));
}
}
}
}