public void ShouldAddErrorsCorrectly()
        {
            var result = PaginatedResult <int> .Success(null, 1, 1, 1);

            var result2 = new PaginatedResult <int>(null, 1, 1, 1);

            result.AddError("Error");
            result.AddError("Error");
            result.AddError("Error");

            result2.AddError("Error");
            result2.AddError("Error");
            result2.AddError("Error");
            result2.AddError("Error");
            result2.AddError("Error");

            Assert.Equal(3, result.Errors.Count);
            Assert.Equal(5, result2.Errors.Count);

            var resultError = PaginatedResult <int> .Error("Error");

            var resultError2 = new PaginatedResult <int>("Error");

            resultError.AddError("Error");
            resultError2.AddError("Error");
            resultError2.AddError("Error");

            Assert.Equal(2, resultError.Errors.Count);
            Assert.Equal(3, resultError2.Errors.Count);
        }
        public async Task <IActionResult> GetLogs([FromQuery] LogQuery urlQuery)
        {
            var result = new PaginatedResult <LogDTO>()
            {
                StatusCode = HttpStatusCode.OK
            };

            try
            {
                result = await _logRepository.GetLogs(urlQuery);

                if (result.IsFailure)
                {
                    return(BadRequest(result));
                }
            }
            catch (Exception ex)
            {
                result.StatusCode = HttpStatusCode.InternalServerError;
                result.AddError("Error on GetLogs", ex.Message, GetType().FullName);

                return(StatusCode((int)HttpStatusCode.InternalServerError, result));
            }

            return(Ok(result));
        }
        public void ShouldNotBeSucceededWhenAddError()
        {
            var result = PaginatedResult <int> .Success(null, 1, 1, 1);

            var result2 = new PaginatedResult <int>(null, 1, 1, 1);

            result.AddError("Error");
            result2.AddError("Error");

            Assert.False(result.Succeeded);
            Assert.False(result2.Succeeded);
        }
        public void ShouldBeEmptyWhenAddError()
        {
            var list = new List <int> {
                1, 2, 3
            };

            var result = PaginatedResult <int> .Success(list, 3, 1, 3);

            var result2 = new PaginatedResult <int>(list, 3, 1, 3);

            result.AddError("Error");
            result2.AddError("Error");

            Assert.Empty(result.Data);
            Assert.Empty(result2.Data);
        }