|
8 | 8 | using System.Activities.Validation; |
9 | 9 | using System.Collections.Generic; |
10 | 10 | using System.Linq; |
| 11 | +using System.Threading.Tasks; |
11 | 12 | using Xunit; |
12 | 13 |
|
13 | 14 | namespace TestCases.Workflows; |
@@ -47,7 +48,8 @@ static ExpressionTests() |
47 | 48 | // There's no programmatic way (that I know of) to add assembly references when creating workflows like in these tests. |
48 | 49 | // Adding the custom assembly directly to the expression validator to simulate XAML reference. |
49 | 50 | // The null is for testing purposes. |
50 | | - VbExpressionValidator.Instance = new VbExpressionValidator(new() { typeof(ClassWithCollectionProperties).Assembly, null }); |
| 51 | + VbExpressionValidator.Instance.AddRequiredAssembly(typeof(ClassWithCollectionProperties).Assembly); |
| 52 | + CSharpExpressionValidator.Instance.AddRequiredAssembly(typeof(ClassWithCollectionProperties).Assembly); |
51 | 53 | } |
52 | 54 |
|
53 | 55 | [Theory] |
@@ -424,6 +426,67 @@ public void CSRoslynValidator_ValidatesMoreThan16Arguments() |
424 | 426 | var result = ActivityValidationServices.Validate(sequence, _useValidator); |
425 | 427 | result.Errors.ShouldBeEmpty(); |
426 | 428 | } |
| 429 | + [Fact] |
| 430 | + public void VB_Multithreaded_NoError() |
| 431 | + { |
| 432 | + var activities = new List<Activity>(); |
| 433 | + var tasks = new List<Task>(); |
| 434 | + var results = new List<ValidationResults>(); |
| 435 | + for (var i = 0; i < 20; i++) |
| 436 | + { |
| 437 | + var seq = new Sequence(); |
| 438 | + seq.Variables.Add(new Variable<int>("sum")); |
| 439 | + for (var j = 0; j < 10000; j++) |
| 440 | + { |
| 441 | + seq.Activities.Add(new Assign |
| 442 | + { |
| 443 | + To = new OutArgument<int>(new VisualBasicReference<int>("sum")), |
| 444 | + Value = new InArgument<int>(new VisualBasicValue<int>($"sum + {j}")) |
| 445 | + }); |
| 446 | + } |
| 447 | + } |
| 448 | + foreach (var activity in activities) |
| 449 | + { |
| 450 | + tasks.Add(Task.Run(() => |
| 451 | + { |
| 452 | + results.Add(ActivityValidationServices.Validate(activity, _useValidator)); |
| 453 | + })); |
| 454 | + } |
| 455 | + Task.WaitAll(tasks.ToArray()); |
| 456 | + |
| 457 | + results.All(r => !r.Errors.Any() && !r.Warnings.Any()).ShouldBeTrue(); |
| 458 | + } |
| 459 | + |
| 460 | + [Fact] |
| 461 | + public void CS_Multithreaded_NoError() |
| 462 | + { |
| 463 | + var activities = new List<Activity>(); |
| 464 | + var tasks = new List<Task>(); |
| 465 | + var results = new List<ValidationResults>(); |
| 466 | + for (var i = 0; i < 20; i++) |
| 467 | + { |
| 468 | + var seq = new Sequence(); |
| 469 | + seq.Variables.Add(new Variable<int>("sum")); |
| 470 | + for (var j = 0; j < 10000; j++) |
| 471 | + { |
| 472 | + seq.Activities.Add(new Assign |
| 473 | + { |
| 474 | + To = new OutArgument<int>(new CSharpReference<int>("sum")), |
| 475 | + Value = new InArgument<int>(new CSharpValue<int>($"sum + {j}")) |
| 476 | + }); |
| 477 | + } |
| 478 | + } |
| 479 | + foreach (var activity in activities) |
| 480 | + { |
| 481 | + tasks.Add(Task.Run(() => |
| 482 | + { |
| 483 | + results.Add(ActivityValidationServices.Validate(activity, _useValidator)); |
| 484 | + })); |
| 485 | + } |
| 486 | + Task.WaitAll(tasks.ToArray()); |
| 487 | + |
| 488 | + results.All(r => !r.Errors.Any() && !r.Warnings.Any()).ShouldBeTrue(); |
| 489 | + } |
427 | 490 |
|
428 | 491 | [Fact] |
429 | 492 | public void VBReferenceTypeIsChecked() |
|
0 commit comments