diff --git a/src/Directory.Build.props b/src/Directory.Build.props index db563d9..e737245 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,7 +1,7 @@  - 2.0.0 - + 2.1.0 + beta.1 Morgan Stanley Morgan Stanley Copyright 2023 Morgan Stanley diff --git a/src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs b/src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs index a9c44c9..4bc48b6 100644 --- a/src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs +++ b/src/Examples/WpfFdc3/Fdc3/DesktopAgent.cs @@ -33,7 +33,7 @@ public DesktopAgent() public Task AddContextListener(string? contextType, ContextHandler handler) where T : IContext { - return _currentChannel?.AddContextListener(contextType, handler); + return _currentChannel?.AddContextListener(contextType, handler) ?? throw new Exception("Unable to create listener"); } public Task AddIntentListener(string intent, IntentHandler handler) where T : IContext diff --git a/src/Fdc3.AppDirectory/AppChannel.cs b/src/Fdc3.AppDirectory/AppChannel.cs index dd75ff6..f21c692 100644 --- a/src/Fdc3.AppDirectory/AppChannel.cs +++ b/src/Fdc3.AppDirectory/AppChannel.cs @@ -28,16 +28,16 @@ public class AppChannel /// /// Initializes a new instance of the class. /// - /// The name - /// Exception if name is null - public AppChannel(string name) + /// The ID of the App Channel + /// Exception if ID is null + public AppChannel(string id) { - Name = name ?? throw new ArgumentNullException(nameof(name)); + ID = id ?? throw new ArgumentNullException(nameof(id)); } /// - /// The name of the App Channel. + /// The ID of the App Channel. /// - public string Name { get; set; } + public string ID { get; set; } /// /// A description of how the channel is used. diff --git a/src/Fdc3.AppDirectory/Fdc3App.cs b/src/Fdc3.AppDirectory/Fdc3App.cs index 4c640e4..15f5171 100644 --- a/src/Fdc3.AppDirectory/Fdc3App.cs +++ b/src/Fdc3.AppDirectory/Fdc3App.cs @@ -28,10 +28,13 @@ public class Fdc3App public Fdc3App(string appId, string name, AppType type, object details) { AppId = appId ?? throw new ArgumentNullException(nameof(appId)); +#pragma warning disable CS0618 // Type or member is obsolete Name = name ?? throw new ArgumentNullException( nameof(name)); +#pragma warning restore CS0618 // Type or member is obsolete Type = type; Details = details ?? throw new ArgumentNullException(nameof(details)); } + /// /// The unique application identifier located within a specific application directory instance. /// @@ -43,7 +46,8 @@ public Fdc3App(string appId, string name, AppType type, object details) /// for multiple versions of the same app. The same appName could occur in other directories. /// We are not currently specifying app name conventions in the document. /// - public string Name { get; set; } + [Obsolete("Use `AppId` to identify apps and `Title` for their display names.")] + public string? Name { get; set; } /// /// The technology type that is used to launch and run the application. @@ -147,6 +151,7 @@ public Fdc3App(string appId, string name, AppType type, object details) /// /// An optional set of name value pairs that can be used to deliver custom data from an App Directory to a launcher. /// + [Obsolete] public Dictionary? CustomConfig { get; set; } /// diff --git a/src/Fdc3.AppDirectory/IntentMetadata.cs b/src/Fdc3.AppDirectory/IntentMetadata.cs index 0728891..f387a51 100644 --- a/src/Fdc3.AppDirectory/IntentMetadata.cs +++ b/src/Fdc3.AppDirectory/IntentMetadata.cs @@ -29,10 +29,12 @@ public class IntentMetadata : IIntentMetadata /// The displayName /// The contexts /// Exception contexts is null - public IntentMetadata(string name, string displayName, IEnumerable contexts) + public IntentMetadata(string name, string displayName, IEnumerable contexts) { Name = name; +#pragma warning disable CS0618 // Type or member is obsolete DisplayName = displayName; +#pragma warning restore CS0618 // Type or member is obsolete Contexts = contexts ?? throw new ArgumentNullException(nameof(contexts)); } @@ -44,7 +46,8 @@ public IntentMetadata(string name, string displayName, IEnumerable conte /// /// An optional display name for the intent that may be used in UI instead of the name. /// - public string DisplayName { get; set; } + [Obsolete("Use the intent name for display as display name may vary for each application as it is defined in the app's AppD record.")] + public string? DisplayName { get; set; } /// /// A comma separated list of the types of contexts the intent offered by the application diff --git a/src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs b/src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs index 91c020d..be42cce 100644 --- a/src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs +++ b/src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingPolicy.cs @@ -37,6 +37,11 @@ public override string ConvertName(string name) case "SEDOL": case "LEI": return name; + case "TextPlain": + return "text/plain"; + case "TextMarkdown": + return "text/markdown"; + default: return CamelCase.ConvertName(name); } diff --git a/src/Fdc3.NewtonsoftJson/Serialization/Fdc3CamelCaseNamingStrategy.cs b/src/Fdc3.NewtonsoftJson/Serialization/Fdc3CamelCaseNamingStrategy.cs index 23520ce..3d66c41 100644 --- a/src/Fdc3.NewtonsoftJson/Serialization/Fdc3CamelCaseNamingStrategy.cs +++ b/src/Fdc3.NewtonsoftJson/Serialization/Fdc3CamelCaseNamingStrategy.cs @@ -37,6 +37,10 @@ public override string GetPropertyName(string name, bool hasSpecifiedName) case "SEDOL": case "LEI": return name; + case "TextPlain": + return "text/plain"; + case "TextMarkdown": + return "text/markdown"; default: return base.GetPropertyName(name, hasSpecifiedName); diff --git a/src/Fdc3/Context/Action.cs b/src/Fdc3/Context/Action.cs new file mode 100644 index 0000000..61d2639 --- /dev/null +++ b/src/Fdc3/Context/Action.cs @@ -0,0 +1,34 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public class Action : Context, IContext + { + public Action(string title, IContext context, string? intent, IAppIdentifier? app = null, object? id = null, string? name = null) + : base(ContextTypes.Action, id, name) + { + this.Title = title; + this.Context = context; + this.Intent = intent; + this.App = app; + } + + public string Title { get; private set; } + public IContext Context { get; private set; } + public string? Intent { get; private set; } + public IAppIdentifier? App { get; private set; } + + } +} diff --git a/src/Fdc3/Context/Chart.cs b/src/Fdc3/Context/Chart.cs index 0a39e05..dd83759 100644 --- a/src/Fdc3/Context/Chart.cs +++ b/src/Fdc3/Context/Chart.cs @@ -12,11 +12,13 @@ * and limitations under the License. */ +using System.Collections.Generic; + namespace Finos.Fdc3.Context { public class Chart : Context, IContext { - public Chart(Instrument[] instruments, TimeRange? range = null, object? otherConfig = null, string? style = null, object? id = null, string? name = null) + public Chart(Instrument[] instruments, TimeRange? range = null, IEnumerable? otherConfig = null, string? style = null, object? id = null, string? name = null) : base(ContextTypes.Chart, id, name) { this.Instruments = instruments; @@ -27,7 +29,7 @@ public Chart(Instrument[] instruments, TimeRange? range = null, object? otherCon public Instrument[] Instruments { get; set; } public TimeRange? Range { get; set; } - public object? OtherConfig { get; set; } + public IEnumerable? OtherConfig { get; set; } public string? Style { get; set; } object? IContext.ID => base.ID; diff --git a/src/Fdc3/Context/ChatInitSettings.cs b/src/Fdc3/Context/ChatInitSettings.cs index a37143f..89a77fc 100644 --- a/src/Fdc3/Context/ChatInitSettings.cs +++ b/src/Fdc3/Context/ChatInitSettings.cs @@ -16,20 +16,29 @@ namespace Finos.Fdc3.Context { public class ChatInitSettings : Context, IContext { - public ChatInitSettings(ContactList? members = null, string? initMessage = null, string? chatName = null, object? options = null, object? id = null, string? name = null) + public ChatInitSettings(ContactList? members = null, Message? message = null, string? chatName = null, ChatInitSettingsOptions? options = null, object? id = null, string? name = null) : base(ContextTypes.ChatInitSettings, id, name) { this.Members = members; - this.InitMessage = initMessage; + this.Message = message; this.ChatName = chatName; this.Options = options; } public string? ChatName { get; set; } - public string? InitMessage { get; set; } + public Message? Message { get; set; } public ContactList? Members { get; set; } - public object? Options { get; set; } + public ChatInitSettingsOptions? Options { get; set; } object? IContext.ID => base.ID; } + + public class ChatInitSettingsOptions + { + public bool? GroupRecipients { get; set; } + public bool? IsPublic { get; set; } + public bool? AllowHistoryBrowsing { get; set; } + public bool? AllowMessageCopy { get; set; } + public bool? AllowAddUser { get; set; } + } } diff --git a/src/Fdc3/Context/ChatMessage.cs b/src/Fdc3/Context/ChatMessage.cs new file mode 100644 index 0000000..d28bc19 --- /dev/null +++ b/src/Fdc3/Context/ChatMessage.cs @@ -0,0 +1,29 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public class ChatMessage : Context, IContext, IRecipient + { + public ChatMessage(ChatRoom chatRoom, Message message, object? id = null, string? name = null) + : base(ContextTypes.ChatMessage, id, name) + { + this.ChatRoom = chatRoom; + this.Message = message; + } + + public ChatRoom ChatRoom { get; set; } + public Message Message { get; set; } + } +} diff --git a/src/Fdc3/Context/ChatRoom.cs b/src/Fdc3/Context/ChatRoom.cs new file mode 100644 index 0000000..9cebbb8 --- /dev/null +++ b/src/Fdc3/Context/ChatRoom.cs @@ -0,0 +1,29 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public class ChatRoom : Context, IContext, IRecipient + { + public ChatRoom(object id, string providerName, string? url = null, string? name = null) + : base(ContextTypes.ChatRoom, id, name) + { + this.ProviderName = providerName; + this.Url = url; + } + + public string ProviderName { get; set; } + public string? Url { get; set; } + } +} diff --git a/src/Fdc3/Context/ChatSearchCriteria.cs b/src/Fdc3/Context/ChatSearchCriteria.cs new file mode 100644 index 0000000..bea33d1 --- /dev/null +++ b/src/Fdc3/Context/ChatSearchCriteria.cs @@ -0,0 +1,29 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using System.Collections; + +namespace Finos.Fdc3.Context +{ + public class ChatSearchCriteria : Context, IContext + { + public ChatSearchCriteria(IEnumerable criteria, object? id = null, string? name = null) + : base(ContextTypes.ChatSearchCriteria, id, name) + { + this.Criteria = criteria; + } + + public IEnumerable Criteria { get; set; } + } +} diff --git a/src/Fdc3/Context/Contact.cs b/src/Fdc3/Context/Contact.cs index b3c257c..5027321 100644 --- a/src/Fdc3/Context/Contact.cs +++ b/src/Fdc3/Context/Contact.cs @@ -28,6 +28,6 @@ public class ContactID { public string? Email { get; set; } - public string? FdsId { get; set; } + public string? FDS_ID { get; set; } } } diff --git a/src/Fdc3/Context/ContextTypes.cs b/src/Fdc3/Context/ContextTypes.cs index 50f56da..8e1168b 100644 --- a/src/Fdc3/Context/ContextTypes.cs +++ b/src/Fdc3/Context/ContextTypes.cs @@ -19,8 +19,12 @@ namespace Finos.Fdc3.Context { public static class ContextTypes { + public static readonly string Action = "fdc3.action"; public static readonly string Chart = "fdc3.chart"; public static readonly string ChatInitSettings = "fdc3.chat.initSettings"; + public static readonly string ChatMessage = "fdc3.chat.message"; + public static readonly string ChatRoom = "fdc3.chat.room"; + public static readonly string ChatSearchCriteria = "fdc3.chat.searchCriteria"; public static readonly string Contact = "fdc3.contact"; public static readonly string ContactList = "fdc3.contactList"; public static readonly string Country = "fdc3.country"; @@ -28,17 +32,23 @@ public static class ContextTypes public static readonly string Email = "fdc3.email"; public static readonly string Instrument = "fdc3.instrument"; public static readonly string InstrumentList = "fdc3.instrumentList"; + public static readonly string Message = "fdc3.message"; public static readonly string Nothing = "fdc3.nothing"; public static readonly string Organization = "fdc3.organization"; public static readonly string Portfolio = "fdc3.portfolio"; public static readonly string Position = "fdc3.position"; - public static readonly string TimeRange = "fdc3.timerange"; + public static readonly string TimeRange = "fdc3.timeRange"; + public static readonly string TransactionResult = "fdc3.transactionResult"; public static readonly string Valuation = "fdc3.valuation"; public static IDictionary Map = new Dictionary() { + { ContextTypes.Action, typeof(Action) }, { ContextTypes.Chart, typeof(Chart) }, { ContextTypes.ChatInitSettings, typeof(ChatInitSettings) }, + { ContextTypes.ChatMessage, typeof(ChatMessage) }, + { ContextTypes.ChatRoom, typeof(ChatRoom) }, + { ContextTypes.ChatSearchCriteria, typeof(ChatSearchCriteria) }, { ContextTypes.Contact, typeof(Contact) }, { ContextTypes.ContactList, typeof(ContactList) }, { ContextTypes.Country, typeof(Country) }, @@ -46,11 +56,13 @@ public static class ContextTypes { ContextTypes.Email, typeof(Email) }, { ContextTypes.Instrument, typeof(Instrument) }, { ContextTypes.InstrumentList, typeof(InstrumentList) }, + { ContextTypes.Message, typeof(Message) }, { ContextTypes.Nothing, typeof(Nothing) }, { ContextTypes.Organization, typeof(Organization) }, { ContextTypes.Portfolio, typeof(Portfolio) }, { ContextTypes.Position, typeof(Position) }, { ContextTypes.TimeRange, typeof(TimeRange) }, + { ContextTypes.TransactionResult, typeof(TransactionResult) }, { ContextTypes.Valuation, typeof(Valuation) }, }; diff --git a/src/Fdc3/Context/Instrument.cs b/src/Fdc3/Context/Instrument.cs index 788f56f..797e7d1 100644 --- a/src/Fdc3/Context/Instrument.cs +++ b/src/Fdc3/Context/Instrument.cs @@ -21,6 +21,8 @@ public Instrument(InstrumentID? id = null, string? name = null) { } + public MarketSource? Market { get; set; } + object? IContext.ID => base.ID; } @@ -36,4 +38,12 @@ public class InstrumentID public string? SEDOL { get; set; } public string? Ticker { get; set; } } + + public class MarketSource + { + public string? BBG { get; set; } + public string? COUNTRY_ISOALPHA2 { get; set; } + public string? MIC { get; set; } + public string? Name { get; set; } + } } diff --git a/src/Fdc3/Context/Message.cs b/src/Fdc3/Context/Message.cs new file mode 100644 index 0000000..f8fbe53 --- /dev/null +++ b/src/Fdc3/Context/Message.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public class Message : Context, IContext + { + public Message(MessageText text, object? id = null, string? name = null) + : base(ContextTypes.Message, id, name) + { + this.Text = text; + } + + public MessageText Text { get; set; } + } + + public class MessageText + { + public string? TextPlain { get; set; } + public string? TextMarkdown { get; set; } + } +} diff --git a/src/Fdc3/Context/TransactionResult.cs b/src/Fdc3/Context/TransactionResult.cs new file mode 100644 index 0000000..fa7c08e --- /dev/null +++ b/src/Fdc3/Context/TransactionResult.cs @@ -0,0 +1,31 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public class TransactionResult : Context, IContext + { + public TransactionResult(string status, IContext? context = null, string? message = null, object? id = null, string? name = null) + : base(ContextTypes.TransactionResult, id, name) + { + this.Status = status; + this.Context = context; + this.Message = message; + } + + public string Status { get; set; } + public IContext? Context; + public string? Message { get; set; } + } +} diff --git a/src/Fdc3/Context/TransactionResultStatus.cs b/src/Fdc3/Context/TransactionResultStatus.cs new file mode 100644 index 0000000..61b346c --- /dev/null +++ b/src/Fdc3/Context/TransactionResultStatus.cs @@ -0,0 +1,24 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +namespace Finos.Fdc3.Context +{ + public static class TransactionResultStatus + { + public static readonly string Created = "Created"; + public static readonly string Deleted = "Deleted"; + public static readonly string Updated = "Updated"; + public static readonly string Failed = "Failed"; + } +} diff --git a/src/Fdc3/Errors.cs b/src/Fdc3/Errors.cs index 0bcbfe2..fdb5429 100644 --- a/src/Fdc3/Errors.cs +++ b/src/Fdc3/Errors.cs @@ -20,6 +20,7 @@ public static class OpenError public static readonly string ErrorOnLaunch = nameof(ErrorOnLaunch); public static readonly string AppTimeout = nameof(AppTimeout); public static readonly string ResolverUnavailable = nameof(ResolverUnavailable); + public static readonly string MalformedContext = nameof(MalformedContext); } public static class ResolveError @@ -31,6 +32,7 @@ public static class ResolveError public static readonly string TargetAppUnavailable = nameof(TargetAppUnavailable); public static readonly string TargetInstanceUnavailable = nameof(TargetInstanceUnavailable); public static readonly string IntentDeliveryFailed = nameof(IntentDeliveryFailed); + public static readonly string MalformedContext = nameof(MalformedContext); } public static class ResultError @@ -44,5 +46,6 @@ public static class ChannelError public static readonly string NoChannelFound = nameof(NoChannelFound); public static readonly string AccessDenied = nameof(AccessDenied); public static readonly string CreationFailed = nameof(CreationFailed); + public static readonly string MalformedContext = nameof(MalformedContext); } } diff --git a/src/Fdc3/IIntentMetadata.cs b/src/Fdc3/IIntentMetadata.cs index 26b1d66..11a8853 100644 --- a/src/Fdc3/IIntentMetadata.cs +++ b/src/Fdc3/IIntentMetadata.cs @@ -12,6 +12,8 @@ * and limitations under the License. */ +using System; + namespace Finos.Fdc3 { /// @@ -27,6 +29,7 @@ public interface IIntentMetadata /// /// A friendly display name for the intent that should be used to render UI elements. /// - string DisplayName { get; } + [Obsolete("Use the intent name for display as display name may vary for each application as it is defined in the app's AppD record.")] + string? DisplayName { get; } } } diff --git a/src/Fdc3/IntentMetadata.cs b/src/Fdc3/IntentMetadata.cs index 85d17fc..59b4c44 100644 --- a/src/Fdc3/IntentMetadata.cs +++ b/src/Fdc3/IntentMetadata.cs @@ -21,10 +21,16 @@ namespace Finos.Fdc3 /// public class IntentMetadata : IIntentMetadata { - public IntentMetadata(string name, string displayName) + public IntentMetadata(string name) { this.Name = name ?? throw new ArgumentNullException(nameof(name)); - this.DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName)); + } + + + [Obsolete("Use the intent name for display as display name may vary for each application as it is defined in the app's AppD record.")] + public IntentMetadata(string name, string? displayName = null) : this(name) + { + this.DisplayName = displayName; } /// @@ -35,6 +41,7 @@ public IntentMetadata(string name, string displayName) /// /// A friendly display name for the intent that should be used to render UI elements. /// - public string DisplayName { get; } + [Obsolete("Use the intent name for display as display name may vary for each application as it is defined in the app's AppD record.")] + public string? DisplayName { get; } } } diff --git a/src/Tests/Finos.Fdc3.AppDirectory.Tests/DeserializationTest.cs b/src/Tests/Finos.Fdc3.AppDirectory.Tests/DeserializationTest.cs index ef6453d..8a9928a 100644 --- a/src/Tests/Finos.Fdc3.AppDirectory.Tests/DeserializationTest.cs +++ b/src/Tests/Finos.Fdc3.AppDirectory.Tests/DeserializationTest.cs @@ -20,7 +20,9 @@ public partial class DeserializationTest protected void ValidateApp(Fdc3App app) { Assert.Equal("my-application", app!.AppId); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal("my-application", app.Name); +#pragma warning restore CS0618 // Type or member is obsolete Assert.Equal("My Application", app.Title); Assert.Equal("An example application that uses FDC3 and fully describes itself in an AppD record.", app.Description); Assert.Equal("1.0.0", app.Version); @@ -52,7 +54,9 @@ protected void ValidateApp(Fdc3App app) Assert.Contains("ViewChart", app.Interop!.Intents!.ListensFor!.Keys); Assert.Contains("myApp.GetPrice", app.Interop.Intents.ListensFor.Keys); Assert.Contains("fdc3.instrument", app.Interop!.Intents!.ListensFor!["myApp.GetPrice"].Contexts!); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Equal("Get Price", app.Interop!.Intents!.ListensFor!["myApp.GetPrice"].DisplayName); +#pragma warning restore CS0618 // Type or member is obsolete Assert.Equal("myApp.quote", app.Interop!.Intents!.ListensFor!["myApp.GetPrice"].ResultType); Assert.Equal("ViewChart", app.Interop!.Intents!.ListensFor!["ViewChart"].Name); Assert.Equal("myApp.GetPrice", app.Interop!.Intents!.ListensFor!["myApp.GetPrice"].Name); @@ -64,7 +68,7 @@ protected void ValidateApp(Fdc3App app) Assert.Contains("fdc3.instrument", app.Interop!.UserChannels!.Broadcasts!); Assert.Contains("fdc3.organization", app.Interop!.UserChannels!.ListensFor!); Assert.Single(app.Interop.AppChannels!); - Assert.Equal("myApp.quotes,", app.Interop!.AppChannels!.First().Name); + Assert.Equal("myApp.quotes,", app.Interop!.AppChannels!.First().ID); Assert.Contains("myApp.quote", app.Interop.AppChannels!.First().Broadcasts!); Assert.Contains("fdc3.instrument", app.Interop.AppChannels!.First().ListensFor!); Assert.Contains("fr-FR", app.LocalizedVersions!.Keys); diff --git a/src/Tests/Finos.Fdc3.AppDirectory.Tests/TestJsons/SampleAppForInterop.json b/src/Tests/Finos.Fdc3.AppDirectory.Tests/TestJsons/SampleAppForInterop.json index 2c90618..9b1eb92 100644 --- a/src/Tests/Finos.Fdc3.AppDirectory.Tests/TestJsons/SampleAppForInterop.json +++ b/src/Tests/Finos.Fdc3.AppDirectory.Tests/TestJsons/SampleAppForInterop.json @@ -96,7 +96,7 @@ }, "appChannels": [ { - "name": "myApp.quotes,", + "id": "myApp.quotes,", "description": "Used to share a stream of quotes for currently displayed instrument and may be used to change the currently displayed symbol,", "broadcasts": [ "myApp.quote" ], "listensFor": [ "fdc3.instrument" ] diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ActionTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ActionTests.cs new file mode 100644 index 0000000..d498590 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ActionTests.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class ActionTests : ContextSchemaTest +{ + public ActionTests() + : base("https://fdc3.finos.org/schemas/2.1/context/action.schema.json") + { + } + + [Fact] + public async Task Action_SerializedJsonMatchesSchema() + { + Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); + Fdc3.Context.Action action = new Fdc3.Context.Action("title", instrument, "ViewInstrument", new AppIdentifier("appid", "instanceid")); + await this.ValidateSchema(action); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChartTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChartTests.cs index d00eb04..9b73a21 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChartTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChartTests.cs @@ -19,16 +19,16 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class ChartTests : ContextSchemaTest { public ChartTests() - : base("https://fdc3.finos.org/schemas/2.0/chart.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/chart.schema.json") { } [Fact] - public async void Chart_SerializedJsonMatchesSchema() + public async Task Chart_SerializedJsonMatchesSchema() { Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); TimeRange timeRange = new TimeRange(DateTime.Now.ToString("o"), DateTime.Now.ToString("o")); - var otherConfig = new { A = "Foo", B = "Bar" }; + IContext[] otherConfig = new[] { instrument }; Chart chart = new Chart(new Instrument[] { instrument }, timeRange, otherConfig, ChartStyle.Line, null, "chart"); await this.ValidateSchema(chart); } diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatInitSettingsTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatInitSettingsTests.cs index 802fa9f..559e6c5 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatInitSettingsTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatInitSettingsTests.cs @@ -19,18 +19,18 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class ChatInitSettingsTests : ContextSchemaTest { public ChatInitSettingsTests() - : base("https://fdc3.finos.org/schemas/2.0/chatInitSettings.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/chatInitSettings.schema.json") { } [Fact] - public async void ChatInitSettings_SerializedJsonMatchesSchema() + public async Task ChatInitSettings_SerializedJsonMatchesSchema() { ChatInitSettings chatInitSettings = new ChatInitSettings( - new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }) }), - "initMessage", + new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }) }), + new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" }), "chatName", - new { GroupRecipients = true, @Public = true, AllowHistoryBrowsing = true, AllowMessageCopy = true, AllowAddUser = true }, + new ChatInitSettingsOptions() { GroupRecipients = true, IsPublic = true, AllowHistoryBrowsing = true, AllowMessageCopy = true, AllowAddUser = true }, null, "chatInitSettings" ); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatMessageTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatMessageTests.cs new file mode 100644 index 0000000..d1b2255 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatMessageTests.cs @@ -0,0 +1,35 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class ChatMessageTests : ContextSchemaTest +{ + public ChatMessageTests() + : base("https://fdc3.finos.org/schemas/2.1/context/chatMessage.schema.json") + { + } + + [Fact] + public async Task ChatMessage_SerializedJsonMatchesSchema() + { + dynamic chatRoomID = new { StreamId = "j75xqXy25NB0dacUI3FNBH", AnyOtherKey = "abcdef" }; + ChatRoom chatRoom = new ChatRoom(chatRoomID, "provider", "http://test.com", "name"); + ChatMessage message = new ChatMessage(chatRoom, new Message(new MessageText() { TextPlain = "plaintext", TextMarkdown = "textmarkdown" }, null, "message"), null, "chatmessage"); + + await this.ValidateSchema(message); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatRoomTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatRoomTests.cs new file mode 100644 index 0000000..40b7c15 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatRoomTests.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class ChatroomTests : ContextSchemaTest +{ + public ChatroomTests() + : base("https://fdc3.finos.org/schemas/2.1/context/chatRoom.schema.json") + { + } + + [Fact] + public async Task ChatRoom_SerializedJsonMatchesSchema() + { + dynamic chatRoomID = new { StreamId = "j75xqXy25NB0dacUI3FNBH", AnyOtherKey = "abcdef" }; + ChatRoom chatRoom = new ChatRoom(chatRoomID, "provider", "http://test.com", "name"); + await this.ValidateSchema(chatRoom); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatSearchCriteriaTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatSearchCriteriaTests.cs new file mode 100644 index 0000000..314f3f6 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ChatSearchCriteriaTests.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class ChatSearchCriteriaTests : ContextSchemaTest +{ + public ChatSearchCriteriaTests() + : base("https://fdc3.finos.org/schemas/2.1/context/chatSearchCriteria.schema.json") + { + } + + [Fact] + public async Task ChatSearchCriteria_SerializedJsonMatchesSchema() + { + Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); + ChatSearchCriteria criteria = new ChatSearchCriteria(new object[] { instrument, "searchterm" }); + string json = await this.ValidateSchema(criteria); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactListTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactListTests.cs index 88a73dc..680c87a 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactListTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactListTests.cs @@ -19,14 +19,14 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class ContactListTests : ContextSchemaTest { public ContactListTests() - : base("https://fdc3.finos.org/schemas/2.0/contactList.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/contactList.schema.json") { } [Fact] - public async void ContactList_SerializedJsonMatchesSchema() + public async Task ContactList_SerializedJsonMatchesSchema() { - ContactList contactList = new ContactList(new Contact[] { new Contact(new ContactID { Email = "email", FdsId = "fdsid" }, "contact") }, "contactList"); + ContactList contactList = new ContactList(new Contact[] { new Contact(new ContactID { Email = "email@email.com", FDS_ID = "fdsid" }, "contact") }, "contactList"); await this.ValidateSchema(contactList); } } \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactTests.cs index 18bf9b5..687a3ee 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ContactTests.cs @@ -18,14 +18,14 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class ContactTests : ContextSchemaTest { public ContactTests() - : base("https://fdc3.finos.org/schemas/2.0/contact.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/contact.schema.json") { } [Fact] - public async void Contact_SerializedJsonMatchesSchema() + public async Task Contact_SerializedJsonMatchesSchema() { - Contact contact = new Contact(new ContactID { Email = "email", FdsId = "fdsid" }, "contact"); + Contact contact = new Contact(new ContactID { Email = "email@test.com", FDS_ID = "fdsid" }, "contact"); await this.ValidateSchema(contact); } } \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CountryTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CountryTests.cs index 7c88802..3897ead 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CountryTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CountryTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class CountryTests : ContextSchemaTest { public CountryTests() - : base("https://fdc3.finos.org/schemas/2.0/country.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/country.schema.json") { } [Fact] - public async void Country_SerializedJsonMatchesSchema() + public async Task Country_SerializedJsonMatchesSchema() { Country country = new Country(new CountryID() { ISOALPHA2 = "isoalpha2", ISOALPHA3 = "isoalpha3" }, "country"); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CurrencyTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CurrencyTests.cs index d38355b..e4ce627 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CurrencyTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/CurrencyTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class CurrencyTests : ContextSchemaTest { public CurrencyTests() - : base("https://fdc3.finos.org/schemas/2.0/currency.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/currency.schema.json") { } [Fact] - public async void Currency_SerializedJsonMatchesSchema() + public async Task Currency_SerializedJsonMatchesSchema() { Currency currency = new Currency(new CurrencyID() { CURRENCY_ISOCODE = "AAA" }, "currency"); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/EmailTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/EmailTests.cs index 29c0a5c..92c053c 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/EmailTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/EmailTests.cs @@ -20,14 +20,14 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class EmailTests : ContextSchemaTest { public EmailTests() - : base("https://fdc3.finos.org/schemas/2.0/email.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/email.schema.json") { } [Fact] - public async void Email_Contact_SerializedJsonMatchesSchema() + public async Task Email_Contact_SerializedJsonMatchesSchema() { - Email email = new Email(new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }), "subject", "body", null, "email"); + Email email = new Email(new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }), "subject", "body", null, "email"); string test = await this.ValidateSchema(email); } @@ -37,17 +37,17 @@ public void Email_Contact_DeserializedJsonMatchesProperties() Email? email = this.Deserialize("Finos.Fdc3.NewtonsoftJson.Tests.Context.Examples.email-contact.json"); Assert.NotNull(email); Contact? contact = email?.Recipients as Contact; - Assert.Equal("email", contact?.ID?.Email); - Assert.Equal("fdsid", contact?.ID?.FdsId); + Assert.Equal("email@test.com", contact?.ID?.Email); + Assert.Equal("fdsid", contact?.ID?.FDS_ID); Assert.Equal("subject", email?.Subject); Assert.Equal("body", email?.TextBody); Assert.Equal("email", email?.Name); } [Fact] - public async void Email_ContactList_SerializedJsonMatchesSchema() + public async Task Email_ContactList_SerializedJsonMatchesSchema() { - Email email = new Email(new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }) }), "subject", "body", null, "email"); + Email email = new Email(new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }) }), "subject", "body", null, "email"); await this.ValidateSchema(email); } @@ -58,8 +58,8 @@ public void Email_ContactList_DeserializedJsonMatchesProperties() Assert.NotNull(email); ContactList? contactList = email?.Recipients as ContactList; Contact? contact = contactList?.Contacts?.First(); - Assert.Equal("email", contact?.ID?.Email); - Assert.Equal("fdsid", contact?.ID?.FdsId); + Assert.Equal("email@test.com", contact?.ID?.Email); + Assert.Equal("fdsid", contact?.ID?.FDS_ID); Assert.Equal("subject", email?.Subject); Assert.Equal("body", email?.TextBody); Assert.Equal("email", email?.Name); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contact.json b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contact.json index 8b7e251..7c66672 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contact.json +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contact.json @@ -1,8 +1,8 @@ { "recipients": { "id": { - "email": "email", - "fdsId": "fdsid" + "email": "email@test.com", + "FDS_ID": "fdsid" }, "type": "fdc3.contact" }, diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contactList.json b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contactList.json index bdfb86d..937faa2 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contactList.json +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/Examples/email-contactList.json @@ -3,8 +3,8 @@ "contacts": [ { "id": { - "email": "email", - "fdsId": "fdsid" + "email": "email@test.com", + "FDS_ID": "fdsid" }, "type": "fdc3.contact" } diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentListTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentListTests.cs index ad73a92..8e65bcb 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentListTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentListTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class InstrumentListTests : ContextSchemaTest { public InstrumentListTests() - : base("https://fdc3.finos.org/schemas/2.0/instrumentList.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/instrumentList.schema.json") { } [Fact] - public async void InstrumentList_SerializedJsonMatchesSchema() + public async Task InstrumentList_SerializedJsonMatchesSchema() { InstrumentList instrumentList = new InstrumentList(new Instrument[] { diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentTests.cs index 51a71b8..af27486 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/InstrumentTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class InstrumentTests : ContextSchemaTest { public InstrumentTests() - : base("https://fdc3.finos.org/schemas/2.0/instrument.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/instrument.schema.json") { } [Fact] - public async void Instrument_SerializedJsonMatchesSchema() + public async Task Instrument_SerializedJsonMatchesSchema() { Instrument instrument = new Instrument( new InstrumentID @@ -38,7 +38,16 @@ public async void Instrument_SerializedJsonMatchesSchema() RIC = "RIC", SEDOL = "SEDOL", Ticker = "TICKER" - }, "Instrument"); + }, "Instrument") + { + Market = new MarketSource + { + BBG = "BBG", + COUNTRY_ISOALPHA2 = "COUNTRY_ISOALPHA2", + MIC = "MIC", + Name = "Name" + } + }; await this.ValidateSchema(instrument); } diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/MessageTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/MessageTests.cs new file mode 100644 index 0000000..a08e020 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/MessageTests.cs @@ -0,0 +1,32 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class MessageTests : ContextSchemaTest +{ + public MessageTests() + : base("https://fdc3.finos.org/schemas/2.1/context/message.schema.json") + { + } + + [Fact] + public async Task Message_SerializedJsonMatchesSchema() + { + Message message = new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" }); + string json = await this.ValidateSchema(message); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/NothingTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/NothingTests.cs index f9afbff..22a3b19 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/NothingTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/NothingTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class NothingTests : ContextSchemaTest { public NothingTests() - : base("https://fdc3.finos.org/schemas/2.0/nothing.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/nothing.schema.json") { } [Fact] - public async void Nothing_SerializedJsonMatchesSchema() + public async Task Nothing_SerializedJsonMatchesSchema() { Nothing nothing = new Nothing(); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/OrganizationTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/OrganizationTests.cs index 29ce848..b190b9c 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/OrganizationTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/OrganizationTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class OrganizationTests : ContextSchemaTest { public OrganizationTests() - : base("https://fdc3.finos.org/schemas/2.0/organization.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/organization.schema.json") { } [Fact] - public async void Organization_SerializedJsonMatchesSchema() + public async Task Organization_SerializedJsonMatchesSchema() { Organization organization = new Organization(new OrganizationID() { FDS_ID = "fdc_id", LEI = "lei", PERMID = "permid" }, "organization"); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PortfolioTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PortfolioTests.cs index d04a998..e3104b3 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PortfolioTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PortfolioTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class PortfolioTests : ContextSchemaTest { public PortfolioTests() - : base("https://fdc3.finos.org/schemas/2.0/portfolio.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/portfolio.schema.json") { } [Fact] - public async void Portfolio_SerializedJsonMatchesSchema() + public async Task Portfolio_SerializedJsonMatchesSchema() { Portfolio portfolio = new Portfolio( new Position[] { new Position(0, new Instrument(new InstrumentID() { Ticker = "ticker" })) }, diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PositionTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PositionTests.cs index f939010..9154f29 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PositionTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/PositionTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class PositionTests : ContextSchemaTest { public PositionTests() - : base("https://fdc3.finos.org/schemas/2.0/position.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/position.schema.json") { } [Fact] - public async void Position_SerializedJsonMatchesSchema() + public async Task Position_SerializedJsonMatchesSchema() { Position position = new Position(0, new Instrument(new InstrumentID() { Ticker = "ticker" }), null, "position"); diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TimeRangeTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TimeRangeTests.cs index 73efb1f..ffe77b9 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TimeRangeTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TimeRangeTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class TimeRangeTests : ContextSchemaTest { public TimeRangeTests() - : base("https://fdc3.finos.org/schemas/2.0/timerange.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/timerange.schema.json") { } [Fact] - public async void TimeRange_SerializedJsonMatchesSchema() + public async Task TimeRange_SerializedJsonMatchesSchema() { TimeRange timeRange = new TimeRange( DateTime.Now.ToString("o"), diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TransactionResultTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TransactionResultTests.cs new file mode 100644 index 0000000..7498f37 --- /dev/null +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/TransactionResultTests.cs @@ -0,0 +1,32 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; + +public class TransactionResultTests : ContextSchemaTest +{ + public TransactionResultTests() + : base("https://fdc3.finos.org/schemas/2.1/context/transactionResult.schema.json") + { + } + + [Fact] + public async Task TransactionResult_SerializedJsonMatchesSchema() + { + TransactionResult transactionResult = new TransactionResult("Created", new Contact(new ContactID { Email = "email@test.com", FDS_ID = "fdsid" }, "contact"), "message"); + await this.ValidateSchema(transactionResult); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ValuationTests.cs b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ValuationTests.cs index 6e0afa9..8398c9e 100644 --- a/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ValuationTests.cs +++ b/src/Tests/Finos.Fdc3.NewtonsoftJson.Tests/Context/ValuationTests.cs @@ -19,12 +19,12 @@ namespace Finos.Fdc3.NewtonsoftJson.Tests.Context; public class ValuationTests : ContextSchemaTest { public ValuationTests() - : base("https://fdc3.finos.org/schemas/2.0/valuation.schema.json") + : base("https://fdc3.finos.org/schemas/2.1/context/valuation.schema.json") { } [Fact] - public async void Valuation_SerializedJsonMatchesSchema() + public async Task Valuation_SerializedJsonMatchesSchema() { var valuation = new Valuation("AAA", 1, 1, DateTime.Now.ToString("o"), DateTime.Now.ToString("o"), null, "valuation"); diff --git a/src/Tests/Finos.Fdc3.SystemTextJson.Tests/EmailTests.cs b/src/Tests/Finos.Fdc3.SystemTextJson.Tests/EmailTests.cs index 720d825..7cd7f5c 100644 --- a/src/Tests/Finos.Fdc3.SystemTextJson.Tests/EmailTests.cs +++ b/src/Tests/Finos.Fdc3.SystemTextJson.Tests/EmailTests.cs @@ -27,8 +27,8 @@ public void Email_Contact_DeserializedJsonMatchesProperties() Email? email = Deserialize("Finos.Fdc3.SystemTextJson.Tests.Examples.email-contact.json"); Assert.NotNull(email); Contact? contact = email?.Recipients as Contact; - Assert.Equal("email", contact?.ID?.Email); - Assert.Equal("fdsid", contact?.ID?.FdsId); + Assert.Equal("email@test.com", contact?.ID?.Email); + Assert.Equal("fdsid", contact?.ID?.FDS_ID); Assert.Equal("subject", email?.Subject); Assert.Equal("body", email?.TextBody); Assert.Equal("email", email?.Name); @@ -41,8 +41,8 @@ public void Email_ContactList_DeserializedJsonMatchesProperties() Assert.NotNull(email); ContactList? contactList = email?.Recipients as ContactList; Contact? contact = contactList?.Contacts?.First(); - Assert.Equal("email", contact?.ID?.Email); - Assert.Equal("fdsid", contact?.ID?.FdsId); + Assert.Equal("email@test.com", contact?.ID?.Email); + Assert.Equal("fdsid", contact?.ID?.FDS_ID); Assert.Equal("subject", email?.Subject); Assert.Equal("body", email?.TextBody); Assert.Equal("email", email?.Name); diff --git a/src/Tests/Finos.Fdc3.Tests/AppIntentTests.cs b/src/Tests/Finos.Fdc3.Tests/AppIntentTests.cs index f27e6d1..8c49f30 100644 --- a/src/Tests/Finos.Fdc3.Tests/AppIntentTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/AppIntentTests.cs @@ -28,14 +28,22 @@ public void AppIntent_NullIntent_ThrowsArgumentNullException() public void AppIntent_NullApps_ThrowsArgumentNullException() { #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0612 // Type or member is obsolete +#pragma warning disable CS0618 // Type or member is obsolete Assert.Throws(() => new AppIntent(new IntentMetadata("name", "displayName"), null)); +#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. } [Fact] public void AppIntent_NonNullParams_PropertyMatchesParam() { +#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0612 // Type or member is obsolete IIntentMetadata metadata = new IntentMetadata("name", "displayName"); +#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete IAppMetadata[] apps = { new AppMetadata("appid") }; IAppIntent appIntent = new AppIntent(metadata, apps); diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ActionTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ActionTests.cs new file mode 100644 index 0000000..115bbd3 --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/ActionTests.cs @@ -0,0 +1,34 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.Tests.Context; + +public class ActionTests +{ + [Fact] + public void Action_PropertiesMatchParams() + { + Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); + Fdc3.Context.Action action = new Fdc3.Context.Action("title", instrument, "ViewInstrument", new AppIdentifier("appid", "instanceid")); + + Assert.Same("title", action.Title); + Assert.Equal(instrument, action.Context); + Assert.Same("TICKER", (action.Context as Instrument)?.ID?.Ticker); + Assert.Same("appid", action.App?.AppId); + Assert.Same("instanceid", action.App?.InstanceId); + + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ChartTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ChartTests.cs index 5626e37..41f93a7 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/ChartTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/ChartTests.cs @@ -23,7 +23,7 @@ public void Chart_PropertiesMatchParams() { Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); TimeRange timeRange = new TimeRange(DateTime.Now.ToString("o"), DateTime.Now.ToString("o")); - var otherConfig = new { A = "Foo", B = "Bar" }; + var otherConfig = new [] { instrument }; Chart chart = new Chart(new Instrument[] { instrument }, timeRange, otherConfig, ChartStyle.Line, null, "chart"); Assert.Same("TICKER", chart?.Instruments?.First()?.ID?.Ticker); diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ChatInitSettingsTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ChatInitSettingsTests.cs index dd02b56..1565b89 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/ChatInitSettingsTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/ChatInitSettingsTests.cs @@ -21,19 +21,20 @@ public class ChatInitSettingsTests [Fact] public void ChatInitSettings_PropertiesMatchParams() { - var options = new { GroupRecipients = true, @Public = true, AllowHistoryBrowsing = true, AllowMessageCopy = true, AllowAddUser = true }; + ChatInitSettingsOptions options = new ChatInitSettingsOptions() { GroupRecipients = true, IsPublic = true, AllowHistoryBrowsing = true, AllowMessageCopy = true, AllowAddUser = true }; + Message message = new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" }); ChatInitSettings chatInitSettings = new ChatInitSettings( - new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }) }), - "initMessage", + new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }) }), + message, "chatName", options, null, "chatInitSettings" ); - Assert.Same("email", chatInitSettings?.Members?.Contacts?.First()?.ID?.Email); + Assert.Same("email@test.com", chatInitSettings?.Members?.Contacts?.First()?.ID?.Email); Assert.Same(options, chatInitSettings?.Options); - Assert.Same("initMessage", chatInitSettings?.InitMessage); + Assert.Same(message, chatInitSettings?.Message); Assert.Same("chatName", chatInitSettings?.ChatName); Assert.Same("chatInitSettings", chatInitSettings?.Name); Assert.Same(ContextTypes.ChatInitSettings, chatInitSettings?.Type); diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ChatMessageTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ChatMessageTests.cs new file mode 100644 index 0000000..8c2acda --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/ChatMessageTests.cs @@ -0,0 +1,38 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; +using System; + +namespace Finos.Fdc3.Tests.Context; + +public class ChatMessageTests +{ + [Fact] + public void ChatMessage_PropertiesMatchParams() + { + dynamic chatRoomID = new { StreamId = "j75xqXy25NB0dacUI3FNBH", AnyOtherKey = "abcdef" }; + ChatRoom chatRoom = new ChatRoom(chatRoomID, "provider", "http://test.com", "name"); + ChatMessage message = new ChatMessage(chatRoom, new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" }, null, "message"), null, "chatmessage"); + + Assert.Equal(chatRoomID, message.ChatRoom.ID); + Assert.Same("http://test.com", message.ChatRoom.Url); + Assert.Same("name", message.ChatRoom.Name); + Assert.Same(ContextTypes.ChatRoom, message.ChatRoom.Type); + Assert.Same("textplain", message.Message.Text.TextPlain); + Assert.Same("textmarkdown", message.Message.Text.TextMarkdown); + Assert.Same(ContextTypes.Message, message.Message.Type); + Assert.Same(ContextTypes.ChatMessage, message.Type); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ChatRoomTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ChatRoomTests.cs new file mode 100644 index 0000000..e0e5031 --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/ChatRoomTests.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; +using System; + +namespace Finos.Fdc3.Tests.Context; + +public class ChatRoomTests +{ + [Fact] + public void ChatRoom_PropertiesMatchParams() + { + dynamic chatRoomID = new { StreamId = "j75xqXy25NB0dacUI3FNBH", AnyOtherKey = "abcdef" }; + ChatRoom chatRoom = new ChatRoom(chatRoomID, "provider", "http://test.com", "name"); + + Assert.Equal(chatRoomID, chatRoom.ID); + Assert.Same("http://test.com", chatRoom.Url); + Assert.Same("name", chatRoom.Name); + Assert.Same(ContextTypes.ChatRoom, chatRoom.Type); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ChatSearchCriteriaTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ChatSearchCriteriaTests.cs new file mode 100644 index 0000000..618f7c5 --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/ChatSearchCriteriaTests.cs @@ -0,0 +1,32 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; +using System; + +namespace Finos.Fdc3.Tests.Context; + +public class ChatSearchCriteriaTests +{ + [Fact] + public void ChatSearchCriteria_PropertiesMatchParams() + { + Instrument instrument = new Instrument(new InstrumentID { Ticker = "TICKER" }); + ChatSearchCriteria criteria = new ChatSearchCriteria(new object[] { instrument, "searchterm" }); + + Assert.Equal(instrument, criteria.Criteria.Cast().First()); + Assert.Same("searchterm", criteria.Criteria.Cast().Last()); + Assert.Same(ContextTypes.ChatSearchCriteria, criteria.Type); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ContactListTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ContactListTests.cs index cfd7fee..1be7007 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/ContactListTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/ContactListTests.cs @@ -21,9 +21,9 @@ public class ContactListTests [Fact] public void ContactList_PropertiesMatchParams() { - ContactList contactList = new ContactList(new Contact[] { new Contact(new ContactID { Email = "email", FdsId = "fdsid" }, "contact") }, "contactList"); + ContactList contactList = new ContactList(new Contact[] { new Contact(new ContactID { Email = "email@test.com", FDS_ID = "fdsid" }, "contact") }, "contactList"); - Assert.Same("email", contactList?.Contacts?.First()?.ID?.Email); + Assert.Same("email@test.com", contactList?.Contacts?.First()?.ID?.Email); Assert.Same("contactList", contactList?.Name); Assert.Same(ContextTypes.ContactList, contactList?.Type); } diff --git a/src/Tests/Finos.Fdc3.Tests/Context/ContactTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/ContactTests.cs index 83dfc87..4cd0175 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/ContactTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/ContactTests.cs @@ -20,9 +20,9 @@ public class ContactTests [Fact] public void Contact_PropertiesMatchParams() { - Contact contact = new Contact(new ContactID { Email = "email", FdsId = "fdsid" }, "contact"); + Contact contact = new Contact(new ContactID { Email = "email@test.com", FDS_ID = "fdsid" }, "contact"); - Assert.Same("email", contact?.ID?.Email); + Assert.Same("email@test.com", contact?.ID?.Email); Assert.Same("contact", contact?.Name); Assert.Same(ContextTypes.Contact, contact?.Type); } diff --git a/src/Tests/Finos.Fdc3.Tests/Context/EmailTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/EmailTests.cs index 1105504..a88ec89 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/EmailTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/EmailTests.cs @@ -21,9 +21,9 @@ public class EmailTests [Fact] public void Email_Contact_PropertiesMatchParams() { - Email email = new Email(new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }), "subject", "body", null, "email"); + Email email = new Email(new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }), "subject", "body", null, "email"); - Assert.Same("email", (email?.Recipients as Contact)?.ID?.Email); + Assert.Same("email@test.com", (email?.Recipients as Contact)?.ID?.Email); Assert.Same("email", email?.Name); Assert.Same(ContextTypes.Email, email?.Type); } @@ -31,9 +31,9 @@ public void Email_Contact_PropertiesMatchParams() [Fact] public void Email_ContactList_PropertiesMatchParams() { - Email email = new Email(new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email", FdsId = "fdsid" }) }), "subject", "body", null, "email"); + Email email = new Email(new ContactList(new Contact[] { new Contact(new ContactID() { Email = "email@test.com", FDS_ID = "fdsid" }) }), "subject", "body", null, "email"); - Assert.Same("email", (email?.Recipients as ContactList)?.Contacts?.First()?.ID?.Email); + Assert.Same("email@test.com", (email?.Recipients as ContactList)?.Contacts?.First()?.ID?.Email); Assert.Same("email", email?.Name); Assert.Same(ContextTypes.Email, email?.Type); } diff --git a/src/Tests/Finos.Fdc3.Tests/Context/InstrumentTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/InstrumentTests.cs index 9a6dc58..15c2ead 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/InstrumentTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/InstrumentTests.cs @@ -33,7 +33,16 @@ public void Instrument_PropertiesMatchParams() RIC = "RIC", SEDOL = "SEDOL", Ticker = "TICKER" - }, "Instrument"); + }, "Instrument") + { + Market = new MarketSource + { + BBG = "BBG", + COUNTRY_ISOALPHA2 = "COUNTRY_ISOALPHA2", + MIC = "MIC", + Name = "Name" + } + }; Assert.Same("BBG", instrument?.ID?.BBG); Assert.Same("CUSIP", instrument?.ID?.CUSIP); @@ -45,6 +54,10 @@ public void Instrument_PropertiesMatchParams() Assert.Same("SEDOL", instrument?.ID?.SEDOL); Assert.Same("TICKER", instrument?.ID?.Ticker); Assert.Same("Instrument", instrument?.Name); + Assert.Same("BBG", instrument?.Market?.BBG); + Assert.Same("COUNTRY_ISOALPHA2", instrument?.Market?.COUNTRY_ISOALPHA2); + Assert.Same("MIC", instrument?.Market?.MIC); + Assert.Same("Name", instrument?.Market?.Name); Assert.Same(ContextTypes.Instrument, instrument?.Type); } } \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/MessageTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/MessageTests.cs new file mode 100644 index 0000000..4a09e5c --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/MessageTests.cs @@ -0,0 +1,30 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; + +namespace Finos.Fdc3.Tests.Context; + +public class MessageTests +{ + [Fact] + public void Message_PropertiesMatchParams() + { + Message message = new Message(new MessageText() { TextPlain = "textplain", TextMarkdown = "textmarkdown" }); + + Assert.Same("textplain", message.Text.TextPlain); + Assert.Same("textmarkdown", message.Text.TextMarkdown); + Assert.Same(ContextTypes.Message, message?.Type); + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/TimeRangeTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/TimeRangeTests.cs index f523104..b581263 100644 --- a/src/Tests/Finos.Fdc3.Tests/Context/TimeRangeTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/Context/TimeRangeTests.cs @@ -33,5 +33,6 @@ public void TimeRange_PropertiesMatchParams() Assert.Same(startTime, timeRange.StartTime); Assert.Same(endTime, timeRange.EndTime); Assert.Same("timerange", timeRange.Name); + Assert.Same(ContextTypes.TimeRange, timeRange.Type); } } \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/Context/TransactionResultTests.cs b/src/Tests/Finos.Fdc3.Tests/Context/TransactionResultTests.cs new file mode 100644 index 0000000..c0dd752 --- /dev/null +++ b/src/Tests/Finos.Fdc3.Tests/Context/TransactionResultTests.cs @@ -0,0 +1,33 @@ +/* + * Morgan Stanley makes this available to you under the Apache License, + * Version 2.0 (the "License"). You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0. + * + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. Unless required by applicable law or agreed + * to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions + * and limitations under the License. + */ + +using Finos.Fdc3.Context; +using System; + +namespace Finos.Fdc3.Tests.Context; + +public class TransactionResultTests +{ + [Fact] + public void TransactionResult_PropertiesMatchParams() + { + Contact contact = new Contact(new ContactID { Email = "email@test.com", FDS_ID = "fdsid" }, "contact"); + TransactionResult result = new TransactionResult("Created", contact, "message"); + + Assert.Same("Created", result.Status); + Assert.Equal(contact, result.Context); + Assert.Same("message", result.Message); + Assert.Same(ContextTypes.TransactionResult, result.Type) ; + } +} \ No newline at end of file diff --git a/src/Tests/Finos.Fdc3.Tests/IntentMetadataTests.cs b/src/Tests/Finos.Fdc3.Tests/IntentMetadataTests.cs index 68cc8cb..590a7cd 100644 --- a/src/Tests/Finos.Fdc3.Tests/IntentMetadataTests.cs +++ b/src/Tests/Finos.Fdc3.Tests/IntentMetadataTests.cs @@ -20,23 +20,36 @@ public class IntentMetadataTests public void IntentMetadata_NullName_ArgumentNullException() { #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. +#pragma warning disable CS0612 // Type or member is obsolete +#pragma warning disable CS0618 // Type or member is obsolete Assert.Throws(() => new IntentMetadata(null, "displayname")); +#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. } [Fact] - public void IntentMetadata_NullDisplayName_ArgumentNullException() + public void IntentMetadata_PropertiesMatchParamsFromCtor1() { -#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. - Assert.Throws(() => new IntentMetadata("name", null)); -#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. + IIntentMetadata metadata = new IntentMetadata("name"); + Assert.Same("name", metadata.Name); +#pragma warning disable CS0618 // Type or member is obsolete + Assert.Null(metadata.DisplayName); +#pragma warning restore CS0618 // Type or member is obsolete } + [Fact] - public void IntentMetadata_PropertiesMatchParams() + public void IntentMetadata_PropertiesMatchParamsFromCtor2() { +#pragma warning disable CS0618 // Type or member is obsolete +#pragma warning disable CS0612 // Type or member is obsolete IIntentMetadata metadata = new IntentMetadata("name", "displayname"); +#pragma warning restore CS0618 // Type or member is obsolete +#pragma warning restore CS0612 // Type or member is obsolete Assert.Same("name", metadata.Name); +#pragma warning disable CS0618 // Type or member is obsolete Assert.Same("displayname", metadata.DisplayName); +#pragma warning restore CS0618 // Type or member is obsolete } } \ No newline at end of file