Ejemplo n.º 1
0
        public void CancellationToken_ShouldReturnCorrectValue(
            )
        {
            //arrange
            var source = new CancellationTokenSource();
            var sut    = new TestAsyncQuery(source.Token);

            //act
            source.Cancel();

            //assert
            sut.CancellationToken.IsCancellationRequested.Should().BeTrue();
        }
        public void When_DispatchAsync_is_called_explicitly_the_query_handler_should_return_success_string()
        {
            // Arrange
            var query        = new TestAsyncQuery();
            var queryHandler = new TestAsyncQueryHandler();

            // Arrange mocks
            Mocks <IServiceProvider>()
            .Setup(provider => provider.GetService(typeof(IAsyncQueryHandler <string, TestAsyncQuery>)))
            .Returns(queryHandler);

            // Act
            string result = SystemUnderTest.DispatchAsync <string, TestAsyncQuery>(query).Result;

            // Assert
            result.Should().Be("Success", because: "the query handler returns the string 'Success'");
        }