|
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +using Microsoft.Extensions.Logging; |
| 5 | + |
| 6 | +namespace Microsoft.DurableTask.Abstractions.Tests; |
| 7 | +public class TaskOrchestrationContextVersionTests |
| 8 | +{ |
| 9 | + [Theory] |
| 10 | + [InlineData("1.1", "1.0", 1)] |
| 11 | + [InlineData("1.0", "1.1", -1)] |
| 12 | + [InlineData("1.0", "1.0", 0)] |
| 13 | + [InlineData("", "1.0", -1)] |
| 14 | + [InlineData("1.0", "", 1)] |
| 15 | + [InlineData("", "", 0)] |
| 16 | + [InlineData("1.0.1", "1.0.0", 1)] |
| 17 | + [InlineData("1.0.0", "1.0.1", -1)] |
| 18 | + [InlineData("alpha", "beta", -1)] |
| 19 | + [InlineData("beta", "alpha", 1)] |
| 20 | + [InlineData("alpha", "alpha", 0)] |
| 21 | + public void OrchestrationContext_Version_ComparisonTests(string orchestrationVersion, string otherVersion, int comparisonResult) |
| 22 | + { |
| 23 | + TaskOrchestrationContext orchestrationContext = new TestTaskOrchestrationContext(orchestrationVersion); |
| 24 | + |
| 25 | + if (comparisonResult > 0) |
| 26 | + { |
| 27 | + orchestrationContext.CompareVersionTo(otherVersion).Should().BeGreaterThan(0); |
| 28 | + } |
| 29 | + else if (comparisonResult < 0) |
| 30 | + { |
| 31 | + orchestrationContext.CompareVersionTo(otherVersion).Should().BeLessThan(0); |
| 32 | + } |
| 33 | + else |
| 34 | + { |
| 35 | + orchestrationContext.CompareVersionTo(otherVersion).Should().Be(0); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + class TestTaskOrchestrationContext : TaskOrchestrationContext |
| 40 | + { |
| 41 | + internal readonly string version = string.Empty; |
| 42 | + |
| 43 | + public TestTaskOrchestrationContext(string version) |
| 44 | + { |
| 45 | + this.version = version; |
| 46 | + } |
| 47 | + public override TaskName Name => throw new NotImplementedException(); |
| 48 | + |
| 49 | + public override string InstanceId => throw new NotImplementedException(); |
| 50 | + |
| 51 | + public override ParentOrchestrationInstance? Parent => throw new NotImplementedException(); |
| 52 | + |
| 53 | + public override DateTime CurrentUtcDateTime => throw new NotImplementedException(); |
| 54 | + |
| 55 | + public override bool IsReplaying => throw new NotImplementedException(); |
| 56 | + |
| 57 | + public override string Version => this.version; |
| 58 | + |
| 59 | + protected override ILoggerFactory LoggerFactory => throw new NotImplementedException(); |
| 60 | + |
| 61 | + public override Task<TResult> CallActivityAsync<TResult>(TaskName name, object? input = null, TaskOptions? options = null) |
| 62 | + { |
| 63 | + throw new NotImplementedException(); |
| 64 | + } |
| 65 | + |
| 66 | + public override Task<TResult> CallSubOrchestratorAsync<TResult>(TaskName orchestratorName, object? input = null, TaskOptions? options = null) |
| 67 | + { |
| 68 | + throw new NotImplementedException(); |
| 69 | + } |
| 70 | + |
| 71 | + public override void ContinueAsNew(object? newInput = null, bool preserveUnprocessedEvents = true) |
| 72 | + { |
| 73 | + throw new NotImplementedException(); |
| 74 | + } |
| 75 | + |
| 76 | + public override Task CreateTimer(DateTime fireAt, CancellationToken cancellationToken) |
| 77 | + { |
| 78 | + throw new NotImplementedException(); |
| 79 | + } |
| 80 | + |
| 81 | + public override T? GetInput<T>() where T : default |
| 82 | + { |
| 83 | + throw new NotImplementedException(); |
| 84 | + } |
| 85 | + |
| 86 | + public override Guid NewGuid() |
| 87 | + { |
| 88 | + throw new NotImplementedException(); |
| 89 | + } |
| 90 | + |
| 91 | + public override void SendEvent(string instanceId, string eventName, object payload) |
| 92 | + { |
| 93 | + throw new NotImplementedException(); |
| 94 | + } |
| 95 | + |
| 96 | + public override void SetCustomStatus(object? customStatus) |
| 97 | + { |
| 98 | + throw new NotImplementedException(); |
| 99 | + } |
| 100 | + |
| 101 | + public override Task<T> WaitForExternalEvent<T>(string eventName, CancellationToken cancellationToken = default) |
| 102 | + { |
| 103 | + throw new NotImplementedException(); |
| 104 | + } |
| 105 | + } |
| 106 | +} |
0 commit comments