Ejemplo n.º 1
0
        public async Task DeleteGeolocationDataByIP_WithIPParameter_ReturnsOkObjectResult()
        {
            var ip = "89.64.27.223";

            var ipDataDTO = new IPDataDTO {
                IPParameter = ip
            };

            var contents = new StringContent(JsonConvert.SerializeObject(ipDataDTO), Encoding.UTF8, "application/json");

            await _client.PostAsync($"/IP/AddGeolocationDataByIP", contents);

            HttpRequestMessage request = new HttpRequestMessage
            {
                Content    = contents,
                Method     = HttpMethod.Delete,
                RequestUri = new Uri("/IP/DeleteGeolocationDataByIP", UriKind.Relative)
            };

            var response = await _client.SendAsync(request);

            response.EnsureSuccessStatusCode();

            var responseResult = await response.Content.ReadAsStringAsync();

            responseResult.Should().Contain("Entry found in DB. Deletion completed");
        }
Ejemplo n.º 2
0
        public async Task AddGeolocationDataByIP_WithIPParameter_ReturnsOkObjectResult()
        {
            var ip = "89.64.27.223";

            var ipDataDTO = new IPDataDTO {
                IPParameter = ip
            };

            var contents = new StringContent(JsonConvert.SerializeObject(ipDataDTO), Encoding.UTF8, "application/json");

            var response = await _client.PostAsync($"/IP/AddGeolocationDataByIP", contents);

            response.EnsureSuccessStatusCode();

            var responseResult = await response.Content.ReadAsStringAsync();

            responseResult.Should().Contain("Adding new entry based on paramter was successfull");
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> DeleteGeolocationDataByIP([FromBody] IPDataDTO ip)
        {
            var result = await _mediator.Send(new DeleteIPCommand(ip.IPParameter));

            return(Ok(result));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> AddGeolocationDataByIP([FromBody] IPDataDTO ip)
        {
            var result = await _mediator.Send(new AddIPCommand { IPParameter = ip.IPParameter });

            return(Ok(result));
        }