public async Task CreateTaskResultErrorAsync_Errors() { var initialError = CreateErrorListTwoTest(); var resultValue = await ResultErrorFactory.CreateTaskResultError(initialError); Assert.True(resultValue.HasErrors); Assert.True(initialError.SequenceEqual(resultValue.Errors)); }
public async Task ResultErrorBindOkTaskAsync_Ok_NoError() { var initialResult = ResultErrorFactory.CreateTaskResultError(); var addingResult = new ResultError(); var result = await initialResult.ResultErrorBindOkTaskAsync(() => addingResult); Assert.True(result.OkStatus); }
public async Task CreateTaskResultErrorAsync_Error() { var initialError = CreateErrorTest(); var resultValue = await ResultErrorFactory.CreateTaskResultError(initialError); Assert.True(resultValue.HasErrors); Assert.True(initialError.Equals(resultValue.Errors.First())); }
public async Task ResultErrorVoidOkBindAsync_Ok_CallVoid() { var resultOk = ResultErrorFactory.CreateTaskResultError(); var voidObjectMock = new Mock <IVoidObject>(); var resultAfterVoid = await resultOk.ResultErrorVoidOkBindAsync(() => voidObjectMock.Object.TestVoidAsync()); Assert.True(resultAfterVoid.Equals(resultOk.Result)); voidObjectMock.Verify(voidObject => voidObject.TestVoidAsync(), Times.Once); }
public async Task ToResultValueTaskAsync_OkStatus() { var resultNoError = ResultErrorFactory.CreateTaskResultError(); const string value = "OkStatus"; var resultValue = await resultNoError.ToResultValueTaskAsync(value); Assert.True(resultValue.OkStatus); Assert.Equal(value, resultValue.Value); }
public async Task ResultErrorBindOkBadAsync_Ok() { var initialResult = new ResultError(); var addingResult = new ResultError(); var result = await initialResult.ResultErrorBindOkBadAsync(() => ResultErrorFactory.CreateTaskResultError(addingResult), errors => ResultErrorFactory.CreateTaskResultErrorAsync(CreateErrorTest())); Assert.True(result.OkStatus); }
public async Task ResultErrorVoidOkWhereBindAsync_Ok_BadPredicate_NotCallVoid() { var resultOk = ResultErrorFactory.CreateTaskResultError(); var voidObjectMock = new Mock <IVoidObject>(); var resultAfterVoid = await resultOk.ResultErrorVoidOkWhereBindAsync(() => false, action : () => voidObjectMock.Object.TestVoidAsync()); Assert.True(resultAfterVoid.Equals(resultOk.Result)); voidObjectMock.Verify(voidObject => voidObject.TestVoidAsync(), Times.Never); }
public async Task ToResultBindValue_OkStatus() { var resultNoError = ResultErrorFactory.CreateTaskResultError(); const string value = "OkStatus"; var resultValue = ResultValueFactory.CreateTaskResultValue(value); var resultValueAfter = await resultNoError.ToResultBindValueBindAsync(resultValue); Assert.True(resultValueAfter.OkStatus); Assert.Equal(value, resultValueAfter.Value); }
public async Task ToNoContentActionResultAsync_OkRequest() { var result = ResultErrorFactory.CreateTaskResultError(); var actionResult = await result.ToNoContentActionResultTaskAsync(); Assert.IsType <NoContentResult>(actionResult); var noContentResult = (NoContentResult)actionResult; Assert.Equal(StatusCodes.Status204NoContent, noContentResult.StatusCode); }
public async Task ResultErrorBindOkTaskAsync_Bad_NoError() { var initialError = CreateErrorTest(); var initialResult = ResultErrorFactory.CreateTaskResultError(initialError); var addingResult = new ResultError(); var result = await initialResult.ResultErrorBindOkTaskAsync(() => addingResult); Assert.True(result.HasErrors); Assert.True(result.Equals(initialResult.Result)); }
public async Task ResultErrorVoidBadBindAsync_Bad_CallVoid() { var errorsInitial = CreateErrorListTwoTest(); var resultError = ResultErrorFactory.CreateTaskResultError(errorsInitial); var voidObjectMock = new Mock <IVoidObject>(); var resultAfterVoid = await resultError.ResultErrorVoidBadBindAsync(errors => voidObjectMock.Object.TestNumberVoidAsync(errors.Count)); Assert.True(resultAfterVoid.Equals(resultError.Result)); Assert.True(errorsInitial.SequenceEqual(resultAfterVoid.Errors)); voidObjectMock.Verify(voidObject => voidObject.TestNumberVoidAsync(It.IsAny <int>()), Times.Once); }
public async Task ResultErrorVoidOkBindAsync_Bad_NotCallVoid() { var initialError = CreateErrorTest(); var resultError = ResultErrorFactory.CreateTaskResultError(initialError); var voidObjectMock = new Mock <IVoidObject>(); var resultAfterVoid = await resultError.ResultErrorVoidOkBindAsync(() => voidObjectMock.Object.TestVoidAsync()); Assert.True(resultAfterVoid.Equals(resultError.Result)); Assert.True(resultAfterVoid.Errors.Last().Equals(initialError)); voidObjectMock.Verify(voidObject => voidObject.TestVoidAsync(), Times.Never); }
public async Task ResultErrorBindOkBadAsync_Error() { var initialResult = new ResultError(CreateErrorListTwoTest()); var addingResult = new ResultError(); var addingResultBad = new ResultError(CreateErrorTest()); var result = await initialResult.ResultErrorBindOkBadAsync(() => ResultErrorFactory.CreateTaskResultError(addingResult), errors => ResultErrorFactory.CreateTaskResultError(addingResultBad)); Assert.True(result.HasErrors); Assert.Equal(addingResultBad.Errors.Count, result.Errors.Count); }
public async Task ToResultValue_HasErrors() { var error = CreateErrorTest(); var resultHasError = ResultErrorFactory.CreateTaskResultError(error); const string value = "BadStatus"; var resultValue = await resultHasError.ToResultValueTaskAsync(value); Assert.True(resultValue.HasErrors); Assert.Single(resultValue.Errors); Assert.True(error.Equals(resultValue.Errors.Last())); }
public async Task ToResultBindValue_HasErrorsBind() { var resultNoError = ResultErrorFactory.CreateTaskResultError(); var error = CreateErrorTest(); var resultValue = ResultValueFactory.CreateTaskResultValueError <string>(error); var resultValueAfter = await resultNoError.ToResultBindValueBindAsync(resultValue); Assert.True(resultValueAfter.HasErrors); Assert.Single(resultValueAfter.Errors); Assert.True(error.Equals(resultValueAfter.Errors.Last())); }
public async Task ResultErrorVoidOkWhereBindAsync_Bad_BadPredicate_NotCallVoid() { var errorsInitial = CreateErrorListTwoTest(); var resultError = ResultErrorFactory.CreateTaskResultError(errorsInitial); var voidObjectMock = new Mock <IVoidObject>(); var resultAfterVoid = await resultError.ResultErrorVoidOkWhereBindAsync(() => false, action : () => voidObjectMock.Object.TestVoidAsync()); Assert.True(resultAfterVoid.Equals(resultError.Result)); Assert.True(errorsInitial.SequenceEqual(resultAfterVoid.Errors)); voidObjectMock.Verify(voidObject => voidObject.TestNumberVoidAsync(It.IsAny <int>()), Times.Never); }
public async Task ToResultValueBind_HasErrorsBindInitial() { var error = CreateErrorTest(); var resultHasError = ResultErrorFactory.CreateTaskResultError(error); var errors = CreateErrorListTwoTest(); var resultValue = new ResultValue<string>(errors); var resultValueAfter = await resultHasError.ToResultBindValueTaskAsync(resultValue); Assert.True(resultValueAfter.HasErrors); Assert.Single(resultValueAfter.Errors); Assert.True(error.Equals(resultValueAfter.Errors.Last())); }
public async Task ToNoContentActionResultAsync_BadRequest() { var initialError = ErrorData.ErrorTest; var result = ResultErrorFactory.CreateTaskResultError(initialError); var actionResult = await result.ToNoContentActionResultTaskAsync(); Assert.IsType <BadRequestObjectResult>(actionResult); var badRequest = (BadRequestObjectResult)actionResult; var errors = (SerializableError)badRequest.Value; Assert.Equal(StatusCodes.Status400BadRequest, badRequest.StatusCode); Assert.Equal(initialError.ErrorResultType.ToString(), errors.Keys.First()); }
public async Task CreateTaskResultErrorAsync_Ok() { var resultValue = await ResultErrorFactory.CreateTaskResultError(); Assert.True(resultValue.OkStatus); }