コード例 #1
0
 public void ServiceCommand_Constructor_With_Sync_Method_Args_Contains_Correct_Errors_On_Failure()
 {
     var command = new ServiceCommand<Person>(
         executeMethod: () => new Person(),
         getBusinessRulesMethod: () => new[] { new FalseRule1() }
     );
     command.Execute().Errors.First().ErrorMessage.ShouldBe("FalseRule1 failed validation");
 }
コード例 #2
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");
 }
コード例 #3
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");
 }