|
| 1 | +using System.IO; |
| 2 | +using System.Text; |
| 3 | +using System.Text.Json; |
| 4 | +using MyNamespace; |
| 5 | +using NServiceBus.Transport.AzureServiceBus; |
| 6 | +using NUnit.Framework; |
| 7 | + |
| 8 | +[TestFixture] |
| 9 | +public class Options |
| 10 | +{ |
| 11 | + [Test, Explicit] |
| 12 | + public void Dump_Migration() |
| 13 | + { |
| 14 | +#pragma warning disable CS0618 // Type or member is obsolete |
| 15 | + var serializedOptions = JsonSerializer.Serialize(new MigrationTopologyOptions |
| 16 | +#pragma warning restore CS0618 // Type or member is obsolete |
| 17 | + { |
| 18 | + QueueNameToSubscriptionNameMap = { { "Publisher", "PublisherSubscriptionName" } }, |
| 19 | + SubscribedEventToRuleNameMap = { { typeof(NotYetMigratedEvent).FullName, "EventRuleName" } }, |
| 20 | + TopicToPublishTo = "TopicToPublishTo", |
| 21 | + TopicToSubscribeOn = "TopicToSubscribeOn", |
| 22 | + EventsToMigrateMap = [typeof(NotYetMigratedEvent).FullName], |
| 23 | + PublishedEventToTopicsMap = { { typeof(MigratedEvent).FullName, "MigratedEvent" } }, |
| 24 | + SubscribedEventToTopicsMap = { { typeof(MigratedEvent).FullName, ["MigratedEvent"] } } |
| 25 | + }, TopologyOptionsSerializationContext.Default.TopologyOptions); |
| 26 | + |
| 27 | + var builder = new StringBuilder(); |
| 28 | + builder.AppendLine("# start" + "code migration-options"); |
| 29 | + builder.AppendLine(serializedOptions); |
| 30 | + builder.AppendLine("# end" + "code migration-options"); |
| 31 | + |
| 32 | + File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "migration-options.json"), builder.ToString()); |
| 33 | + } |
| 34 | + |
| 35 | + [Test, Explicit] |
| 36 | + public void Dump_Options() |
| 37 | + { |
| 38 | +#pragma warning disable CS0618 // Type or member is obsolete |
| 39 | + var serializedOptions = JsonSerializer.Serialize(new TopologyOptions |
| 40 | +#pragma warning restore CS0618 // Type or member is obsolete |
| 41 | + { |
| 42 | + QueueNameToSubscriptionNameMap = { { "Publisher", "PublisherSubscriptionName" } }, |
| 43 | + PublishedEventToTopicsMap = { { typeof(SomeEvent).FullName, "some-event" } }, |
| 44 | + SubscribedEventToTopicsMap = { { typeof(SomeEvent).FullName, ["some-event"] } } |
| 45 | + }, TopologyOptionsSerializationContext.Default.TopologyOptions); |
| 46 | + |
| 47 | + var builder = new StringBuilder(); |
| 48 | + builder.AppendLine("# start" + "code topology-options"); |
| 49 | + builder.AppendLine(serializedOptions); |
| 50 | + builder.AppendLine("# end" + "code topology-options"); |
| 51 | + |
| 52 | + File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "topology-options.json"), builder.ToString()); |
| 53 | + } |
| 54 | + |
| 55 | + [Test, Explicit] |
| 56 | + public void Dump_Options_Inheritance() |
| 57 | + { |
| 58 | +#pragma warning disable CS0618 // Type or member is obsolete |
| 59 | + var serializedOptions = JsonSerializer.Serialize(new TopologyOptions |
| 60 | +#pragma warning restore CS0618 // Type or member is obsolete |
| 61 | + { |
| 62 | + QueueNameToSubscriptionNameMap = { { "Publisher", "PublisherSubscriptionName" } }, |
| 63 | + PublishedEventToTopicsMap = { { typeof(SomeEvent).FullName, "some-event" } }, |
| 64 | + SubscribedEventToTopicsMap = { { typeof(SomeEvent).FullName, ["some-event", "some-other-event"] } } |
| 65 | + }, TopologyOptionsSerializationContext.Default.TopologyOptions); |
| 66 | + |
| 67 | + var builder = new StringBuilder(); |
| 68 | + builder.AppendLine("# start" + "code topology-options-inheritance"); |
| 69 | + builder.AppendLine(serializedOptions); |
| 70 | + builder.AppendLine("# end" + "code topology-options-inheritance"); |
| 71 | + |
| 72 | + File.WriteAllText(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "topology-options-inheritance.json"), builder.ToString()); |
| 73 | + } |
| 74 | +} |
| 75 | + |
| 76 | +namespace MyNamespace |
| 77 | +{ |
| 78 | + class NotYetMigratedEvent; |
| 79 | + class MigratedEvent; |
| 80 | + |
| 81 | + class SomeEvent; |
| 82 | +} |
0 commit comments