Ejemplo n.º 1
0
        public async Task Should_handle_void_returning_side_effect()
        {
            //Arrange
            var services = new ServiceCollection();

            services.AddScoped <ISideEffectHandler <VoidReturning.SideEffect, Unit>, VoidReturning.Handler>();
            await using var container = services.BuildServiceProvider();
            var sut = new SideEffectBroker(container);

            //Act
            var sideEffectHandlerType = await sut.Run <VoidReturning.SideEffect, Unit>(new VoidReturning.SideEffect());

            //Assert
            sideEffectHandlerType.Should().Be(Unit.Value);
        }
Ejemplo n.º 2
0
        public async Task Should_handle_simple_side_effect()
        {
            //Arrange
            var services = new ServiceCollection();

            services.AddScoped <ISideEffectHandler <Simple.SideEffect, int>, Simple.Handler>();
            await using var container = services.BuildServiceProvider();
            var sut = new SideEffectBroker(container);

            //Act
            var result = await sut.Run <Simple.SideEffect, int>(new Simple.SideEffect(10));

            //Assert
            result.Should().Be(10);
        }
Ejemplo n.º 3
0
        public async Task Should_handle_generic_side_effect()
        {
            //Arrange
            var services = new ServiceCollection();

            services.AddScoped(typeof(Generic.Handler <>));
            await using var container = services.BuildServiceProvider();
            var sut = new SideEffectBroker(container);

            //Act
            var sideEffectHandler = await sut.Run <Generic.SideEffect <int>, int>(new Generic.SideEffect <int>());


            //Assert
            sideEffectHandler.Should().Be(0);
        }