public async Task <ActionResult <GetNextIfNotPrimeOrCurrentResponse> > Next([FromQuery] GetNextIfNotPrimeOrCurrentRequest request)
        {
            var query             = Mapper.Map <GetNextIfNotPrimeOrCurrentQuery>(request);
            var nextPrimeNumberVm = await Mediator.Send(query);

            var response = Mapper.Map <GetNextIfNotPrimeOrCurrentResponse>(nextPrimeNumberVm);

            return(response);
        }
示例#2
0
        public async Task Get_Next_If_Not_Prime_Or_Current_Returns_BAD_REQUEST(string number)
        {
            var request = new GetNextIfNotPrimeOrCurrentRequest
            {
                Number = number
            };

            var queryString = _queryStringFactory.Create(request);

            var result = await _client.GetAsync($"api/prime-numbers/next{queryString}");

            Assert.Equal(HttpStatusCode.BadRequest, result.StatusCode);
        }
示例#3
0
        public async Task Get_Next_If_Not_Prime_Or_Current_Returns_OK(string number, int outputNumber)
        {
            var request = new GetNextIfNotPrimeOrCurrentRequest
            {
                Number = number
            };

            var queryString = _queryStringFactory.Create(request);

            var result = await _client.GetAsync($"api/prime-numbers/next{queryString}");

            var content = await result.Content.ReadAsStringAsync();

            var response = JsonConvert.DeserializeObject <GetNextIfNotPrimeOrCurrentResponse>(content);

            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
            Assert.Equal(outputNumber, response.Number);
        }