Esempio n. 1
0
        public async Task ServiceCommand_Constructor_With_Async_Method_Args_Contains_Correct_Errors_On_Failure()
        {
            var command = new ServiceCommand <Person>(
                executeAsyncMethod: () => Task.Run(() => new Person()),
                getBusinessRulesAsyncMethod: () => Task.Run <IEnumerable <IRule> >(() => new [] { new FalseRule1() })
                );
            var result = await command.ExecuteAsync();

            result.Errors.First().ErrorMessage.ShouldBe("FalseRule1 failed validation");
        }
        public async Task ServiceCommandOfT_Composition_6()
        {
            var command = new ServiceCommand <Person>
                          (
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("4");
        }
        public async Task ServiceCommandOfT_Composition_2()
        {
            var command = new ServiceCommand <Person>
                          (
                initializationAsyncMethod,
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("14");
        }
        public async Task ServiceCommandOfT_Composition_9()
        {
            var command = new ServiceCommand <Person>
                          (
                getBusinessRulesAsyncMethod,
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("34");
        }
Esempio n. 5
0
        public async Task ServiceCommand_Composition_5()
        {
            var command = new ServiceCommand
                          (
                validationAsyncMethod,
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("24");
        }
Esempio n. 6
0
        public async Task ServiceCommand_Composition_11()
        {
            var command = new ServiceCommand
                          (
                executeAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("4");
        }
Esempio n. 7
0
        public async Task ServiceCommand_Composition_13()
        {
            var command = new ServiceCommand
                          (
                initializationAsyncMethod,
                getBusinessRulesAsyncMethod,
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("134");
        }
Esempio n. 8
0
        public async Task ServiceCommand_Composition_12()
        {
            var command = new ServiceCommand
                          (
                executeAsyncMethod,
                getBusinessRulesAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("34");
        }
Esempio n. 9
0
        public async Task ServiceCommand_Composition_7()
        {
            var command = new ServiceCommand
                          (
                executeMethod,
                getErrorsMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("24");
        }
Esempio n. 10
0
        public async Task ServiceCommand_Composition_3()
        {
            var command = new ServiceCommand
                          (
                initializationMethod,
                executeMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("14");
        }
Esempio n. 11
0
        public async Task ServiceCommandOfT_Composition_15()
        {
            var command = new ServiceCommand <Person>
                          (
                initializationAsyncMethod,
                validationAsyncMethod,
                getBusinessRulesAsyncMethod,
                executeAsyncMethod
                          );

            await command.ExecuteAsync();

            _count.ShouldBe("124");
        }
Esempio n. 12
0
        public async Task ServiceCommand_Composition_14()
        {
            var command = new ServiceCommand
                          (
                initializationAsyncMethod,
                executeAsyncMethod,
                getErrorsAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("124");
        }
Esempio n. 13
0
        public async Task ServiceCommandConstructorWithAsyncAndSyncMethodArgsContainsCorrectErrorsOnFailure()
        {
            var command = new ServiceCommand <Person>(
                executeMethod: () => new Person(),
                executeAsyncMethod: () => Task.Run(() => new Person()),
                getBusinessRulesMethod: () => new[] { new FalseRule1() },
                getBusinessRulesAsyncMethod: () => Task.Run <IEnumerable <IRule> >(() => new [] { new FalseRule2() })
                );

            command.Execute().Errors.First().ErrorMessage.ShouldBe("FalseRule1 failed validation");
            var result = await command.ExecuteAsync();

            result.Errors.First().ErrorMessage.ShouldBe("FalseRule2 failed validation");
        }
Esempio n. 14
0
        public async Task ServiceCommandOfT_Composition_5()
        {
            var command = new ServiceCommand <Person>
                          (
                getErrorsMethod,
                getErrorsAsyncMethod,
                executeMethod,
                executeAsyncMethod
                          );

            command.Execute();
            await command.ExecuteAsync();

            _count.ShouldBe("2424");
        }