Exemplo n.º 1
0
 public Given_a_PostValues_Request()
 {
     validator = new PostValues.Validator();
     request   = new PostValues.Request
     {
         Param1 = "123",
         Param2 = "1234"
     };
 }
        public void Test_ValidatorValidatesIfParam1Of3Digits(string value, bool isValid)
        {
            //Arrange
            request = new PostValues.Request
            {
                Values = new Values
                {
                    Param1 = value,
                    Param2 = "1234"
                }
            };

            //Act and Assert
            Assert.Equal(isValid, validator.Validate(request).IsValid);
        }
        public void Test_ValidatorValidatesIfParam2IsNotNullAndNotEmpty(string value, bool isValid)
        {
            //Arrange
            request = new PostValues.Request
            {
                Values = new Values
                {
                    Param1 = "123",
                    Param2 = value
                }
            };

            //Act and Assert
            Assert.Equal(isValid, validator.Validate(request).IsValid);
        }
Exemplo n.º 4
0
        public async void Test_HandleReturnsCorrectResponse()
        {
            //Arrange
            var handler = new PostValues.Handler();
            var request = new PostValues.Request {
                Values = new Values {
                    Param1 = "param1", Param2 = "param2"
                }
            };

            //Act
            var response = await handler.Handle(request, new CancellationToken());

            //Assert
            Assert.Equal("param1", response.ResultParam1);
            Assert.Equal("param2", response.ResultParam2);
        }
 public async Task <ActionResult <PostValues.Response> > PostValues(PostValues.Request request)
 {
     return(await mediator.Send <PostValues.Response>(request));
 }