Esempio n. 1
0
        //[Fact(Timeout = 10000)]
        public async Task Dead_Node_Should_Not_Block_Dispose()
        {
            using var c = new MockCluster(EP("localhost:64000", "localhost:64002", "localhost:64004", "localhost:64006"),
                                          new DefaultNodeLocator(),
                                          new ImmediateReconnectPolicyFactory(),
                                          new FailNodeFactory());
            {
                c.Start();
                try { await Task.WhenAll(c.Broadcast(_ => new WorkingOperation())); } catch { }

                await Task.Delay(1000);
            }
        }
Esempio n. 2
0
        //[Fact(Timeout = 1000)]
        public async Task Exception_Should_Properly_Bubble_Up()
        {
            using var c = new MockCluster(EP("localhost:64000"),
                                          new DefaultNodeLocator(),
                                          new PeriodicReconnectPolicyFactory(),
                                          new WorkingNodeFactory());

            c.Start();

            var e = await Assert.ThrowsAsync <IOException>(() => c.Execute(new FailingOperation()));

            var nie = Assert.IsType <NotImplementedException>(e.InnerException);

            Assert.Equal(FailingOperation.ExceptionMessage, nie.Message);
        }
        public async Task Query_is_execute_to_get_questions()
        {
            // arrange
            var queryResult = new FakeQueryResult <TriviaQuestion>();

            queryResult.FakeRows = new List <TriviaQuestion>();
            var req = new GetRandomTriviaQuestions(numQuestions: 13);

            MockCluster.Setup(m => m.QueryAsync <TriviaQuestion>(It.IsAny <string>(), It.IsAny <QueryOptions>()))
            .ReturnsAsync(queryResult);

            // act
            var result = await _handler.Handle(req, CancellationToken.None);

            // assert
            MockCluster.Verify(m => m.QueryAsync <TriviaQuestion>(It.IsAny <string>(), It.IsAny <QueryOptions>()),
                               Times.Once);
            var resultList = await result.ToListAsync();

            Assert.That(resultList, Is.Not.Null);
        }
 public ClientTestBase()
 {
     Cluster = new MockCluster();
     ClientId = System.Text.Encoding.Default.GetBytes("fadjskl").Take(4).ToArray();
     Client = new RiakClient(Cluster);
 }