Пример #1
0
        public async Task ResultValueTry_Ok()
        {
            int initialValue = Numbers.Number;

            var resultValue = await ResultErrorTryAsync(() => AsyncFunctions.DivisionAsync(initialValue), Exceptions.ExceptionError());

            Assert.True(resultValue.OkStatus);
        }
Пример #2
0
        public async Task ResultValueTryAsync_Exception()
        {
            const int initialValue = 0;
            var       resultValue  = await ResultValueTryAsync(() => AsyncFunctions.DivisionAsync(initialValue), Exceptions.ExceptionError());

            Assert.True(resultValue.HasErrors);
            Assert.Equal(ErrorResultType.DivideByZero, resultValue.Errors.First().ErrorResultType);
        }
Пример #3
0
        public async Task ResultValueBindTryAsync_Ok()
        {
            int initialValue = Numbers.Number;

            var resultValue = await ResultValueBindTryAsync(() => ResultValueFactory.CreateTaskResultValue(Division(initialValue)),
                                                            Exceptions.ExceptionError());

            Assert.True(resultValue.OkStatus);
            Assert.Equal(resultValue.Value, await AsyncFunctions.DivisionAsync(initialValue));
        }
Пример #4
0
        public async Task ResultValueTryOkAsync_OkResult_OkTry()
        {
            int initialValue = Numbers.Number;
            var numberResult = new ResultValue <int>(initialValue);

            var numberAfterTry = await numberResult.ResultValueTryOkAsync(AsyncFunctions.DivisionAsync, CreateErrorTest());

            Assert.True(numberAfterTry.OkStatus);
            Assert.Equal(await AsyncFunctions.DivisionAsync(initialValue), numberAfterTry.Value);
        }
Пример #5
0
        public async Task ResultValueBindTryOkAsync_OkResult_OkTry()
        {
            int initialValue = Numbers.Number;
            var numberResult = new ResultValue <int>(initialValue);

            var numberAfterTry = await numberResult.ResultValueBindTryOkAsync(
                numbers => ResultValueFactory.CreateTaskResultValue(Division(numbers)), Exceptions.ExceptionError());

            Assert.True(numberAfterTry.OkStatus);
            Assert.Equal(await AsyncFunctions.DivisionAsync(initialValue), numberAfterTry.Value);
        }