From e5d016d51c36b074dbf3d3cc19464d9c6f0bc32b Mon Sep 17 00:00:00 2001 From: v-yilinhu Date: Tue, 17 May 2022 15:26:14 +0800 Subject: [PATCH 1/7] update eventgrid sdk to t2 --- .../Blazor.EventGridViewer.Core.csproj | 4 +- .../Models/CloudEvent.cs | 5 +- .../Models/EventGridEventModel.cs | 12 ++- .../Models/EventGridViewerEventModel.cs | 4 +- .../Blazor.EventGridViewer.ServerApp.csproj | 5 +- .../Controllers/EventGridController.cs | 10 +- .../Pages/Index.razor | 2 +- .../Startup.cs | 1 - .../Adapters/EventGridEventModelAdapter.cs | 2 +- .../Adapters/EventGridSchemaAdapter.cs | 5 +- .../Blazor.EventGridViewer.Services.csproj | 5 +- .../Interfaces/IEventGridService.cs | 3 +- .../Blazor.EventGridViewer.Unit.Tests.csproj | 2 +- src/Blazor.EventGridViewer.Unit.Tests/Data.cs | 92 +++++++++---------- .../EventGridEventModelAdapterTests.cs | 3 +- .../EventGridSchemaAdapterTests.cs | 9 +- 16 files changed, 85 insertions(+), 79 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj index 2b6e4d5..546fc83 100644 --- a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj +++ b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj @@ -1,11 +1,13 @@  - net5.0 + net6.0 + + diff --git a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs index b8aa9c7..6c626dd 100644 --- a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs +++ b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json; +using System; namespace Blazor.EventGridViewer.Core.Models { @@ -21,9 +22,9 @@ public class CloudEvent public string Id { get; set; } [JsonProperty("time")] - public string Time { get; set; } + public DateTimeOffset Time { get; set; } [JsonProperty("data")] - public object Data { get; set; } + public BinaryData Data { get; set; } } } diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs index 16162af..3ac9332 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs @@ -1,4 +1,6 @@ -namespace Blazor.EventGridViewer.Core.Models +using System; + +namespace Blazor.EventGridViewer.Core.Models { /// /// Class used as a model for EventGrid Events @@ -24,10 +26,14 @@ public class EventGridEventModel /// /// EventGrid Data /// - public object EventData { get; set; } + public BinaryData EventData { get; set; } /// /// EventGrid Event Time /// - public string EventTime { get; set; } + public DateTimeOffset EventTime { get; set; } + /// + /// Data Version + /// + public string DataVersion { get; set; } } } diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs index 3bb64d5..c501eff 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs @@ -18,7 +18,7 @@ public class EventGridViewerEventModel /// /// EventGrid Data /// - public string Data { get; set; } + public BinaryData Data { get; set; } /// /// EventGrid Subject /// @@ -26,7 +26,7 @@ public class EventGridViewerEventModel /// /// EventGrid Event Time /// - public string EventTime { get; set; } + public DateTimeOffset EventTime { get; set; } /// /// Unique Id for EventGridViewer Event /// diff --git a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj index b972970..86f1ad5 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj +++ b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj @@ -1,12 +1,13 @@ - + - net5.0 + net6.0 aspnet-Blazor.EventGridViewer.ServerApp-5673166F-2442-4564-A540-4C06195A2FF8 0 + diff --git a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs index 974a46a..944ddb9 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs @@ -8,9 +8,10 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Azure.EventGrid; -using Microsoft.Azure.EventGrid.Models; using Newtonsoft.Json.Linq; +using Azure.Messaging.EventGrid; +using Azure.Messaging.EventGrid.Models; +using Azure.Messaging.EventGrid.SystemEvents; namespace Blazor.EventGridViewer.ServerApp.Controllers { @@ -57,10 +58,11 @@ public async Task Post() foreach (EventGridEventModel model in eventGridEventModels) { + EventGridEvent eventGrid = new EventGridEvent(model.Subject, model.EventType, model.DataVersion, model.EventData); // EventGrid validation message - if (model.EventType == EventTypes.EventGridSubscriptionValidationEvent) + if (eventGrid.TryGetSystemEventData(out object systemEvent)) { - var eventData = ((JObject)(model.EventData)).ToObject(); + var eventData = ((JObject)systemEvent).ToObject(); var responseData = new SubscriptionValidationResponse() { ValidationResponse = eventData.ValidationCode diff --git a/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor b/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor index 2bfd44a..eeb816a 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor +++ b/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor @@ -27,7 +27,7 @@
@model.Data
- +
diff --git a/src/Blazor.EventGridViewer.ServerApp/Startup.cs b/src/Blazor.EventGridViewer.ServerApp/Startup.cs index ef5f640..f11039e 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Startup.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Startup.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Mvc.Authorization; using Microsoft.AspNetCore.Authentication; using Blazor.EventGridViewer.Services.Adapters; -using Microsoft.Azure.EventGrid.Models; using Blazor.EventGridViewer.Core.Models; using System.Collections.Generic; diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs index f1ab592..b78e7ac 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs @@ -21,7 +21,7 @@ public EventGridViewerEventModel Convert(EventGridEventModel t) EventGridViewerEventModel model = new EventGridViewerEventModel() { - Data = t.Data, + Data = t.EventData, EventType = t.EventType, Subject = t.Subject, Id = t.Id, diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs index 1b60897..8581fb5 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs @@ -1,10 +1,11 @@ using Blazor.EventGridViewer.Core; using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Interfaces; -using Microsoft.Azure.EventGrid.Models; +//using Microsoft.Azure.EventGrid.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; +using Azure.Messaging.EventGrid; namespace Blazor.EventGridViewer.Services.Adapters { @@ -84,7 +85,7 @@ private List AdaptEventGridEvent(string t) Subject = string.IsNullOrEmpty(eventGridEvent.Subject) ? eventGridEvent.EventType : eventGridEvent.Subject, Data = json, EventData = eventGridEvent.Data, - EventTime = eventGridEvent.EventTime.ToString("o") // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netcore-3.1 + EventTime = eventGridEvent.EventTime // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netcore-3.1 }; models.Add(model); } diff --git a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj index 6f38cb6..4049166 100644 --- a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj +++ b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj @@ -1,7 +1,7 @@ - + - net5.0 + net6.0 @@ -9,6 +9,7 @@ + diff --git a/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs b/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs index 38cc61c..40b54de 100644 --- a/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs +++ b/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs @@ -1,4 +1,5 @@ -using Blazor.EventGridViewer.Core.CustomEventArgs; +using Azure.Messaging.EventGrid; +using Blazor.EventGridViewer.Core.CustomEventArgs; using Blazor.EventGridViewer.Core.Models; using System; diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj index 8e02c54..7b86879 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj +++ b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs index 24abfea..cee5972 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs @@ -1,4 +1,5 @@ using Newtonsoft.Json.Linq; +using System; namespace Blazor.EventGridViewer.Unit.Tests { @@ -14,24 +15,19 @@ public static class Data public static string GetMockEventGridEventJson() { // Note: guids were generated with an online guid generator - JArray jarray = new JArray(); - jarray.Add( - new JObject - { - ["id"] = "efdae305-d50f-49f6-a6ec-bd632d52bb3b", - ["topic"] = "subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - ["subject"] = "EventGridSubscriptionValidation", - ["data"] = new JObject - { - ["validationCode"] = "595c123c-0b91-4fa1-8b40-36f2e44194c9" - }, - ["eventType"] = "Microsoft.EventGrid.SubscriptionValidationEvent", - ["eventTime"] = "2018-01-25T22:12:19.4556811Z", - ["metadataVersion"] = "1", - ["dataVersion"] = "1" - }); - - return jarray.ToString(); + string mockEventGridEvent = @"[{ + 'id' : 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', + 'topic':'subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', + 'subject':'EventGridSubscriptionValidation', + 'data': { + 'validationCode': '595c123c-0b91-4fa1-8b40-36f2e44194c9' + }, + 'eventType': 'Microsoft.EventGrid.SubscriptionValidationEvent', + 'eventTime': '2018-01-25T22:12:19.4556811Z', + 'metadataVersion': '1', + 'dataVersion': '1' +}]"; + return mockEventGridEvent; } /// @@ -41,22 +37,19 @@ public static string GetMockEventGridEventJson() public static string GetMockCloudEventJson() { // Note: guids were generated with an online guid generator - JObject jobject = new JObject - { - ["specversion"] = "1.0", - ["type"] = "com.github.pull.create", - ["source"] = "https://github.com/cloudevents/spec/pull", - ["subject"] = "123", - ["id"] = "efdae305-d50f-49f6-a6ec-bd632d52bb3b", - ["time"] = "2018-01-25T22:12:19.4556811Z", - ["data"] = new JObject - { - ["make"] = "Ducati", - ["model"] = "Monster" - } - }; - - return jobject.ToString(); + string mockCloudEvent = @"[{ + 'specversion' : '1.0', + 'type':'com.github.pull.create', + 'source':'https://github.com/cloudevents/spec/pull', + 'subject': '123', + 'id': 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', + 'time': '2018-01-25T22:12:19.4556811Z', + 'data': { + 'make': 'Ducati', + 'model':'Monster' + }, +}]"; + return mockCloudEvent; } /// @@ -66,23 +59,20 @@ public static string GetMockCloudEventJson() public static string GetMockCloudEventExtraPropertiesJson() { // Note: guids were generated with an online guid generator - JObject jobject = new JObject - { - ["specversion"] = "1.0", - ["type"] = "com.github.pull.create", - ["source"] = "https://github.com/cloudevents/spec/pull", - ["subject"] = "123", - ["id"] = "efdae305-d50f-49f6-a6ec-bd632d52bb3b", - ["time"] = "2018-01-25T22:12:19.4556811Z", - ["comexampleothervalue"] = "5", - ["data"] = new JObject - { - ["make"] = "Ducati", - ["model"] = "Monster" - } - }; - - return jobject.ToString(); + string mockCloudEventExtraProperties = @"[{ + 'specversion' : '1.0', + 'type':'com.github.pull.create', + 'source':'https://github.com/cloudevents/spec/pull', + 'subject': '123', + 'id': 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', + 'time': '2018-01-25T22:12:19.4556811Z', + 'comexampleothervalue':'5', + 'data': { + 'make': 'Ducati', + 'model':'Monster' + } +}]"; + return mockCloudEventExtraProperties; } } } diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs index c7d075a..4a66f9b 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs @@ -1,6 +1,7 @@ using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Adapters; using Blazor.EventGridViewer.Services.Interfaces; +using System; using Xunit; namespace Blazor.EventGridViewer.Unit.Tests @@ -41,7 +42,7 @@ public void EventGridEventModelAdapterConvertCanConvertEventGridEventModel() // Assert Assert.True(eventGridEventModel.Id == eventGridViewerEventModel.Id && eventGridEventModel.Subject == eventGridViewerEventModel.Subject && - eventGridEventModel.EventType == eventGridViewerEventModel.EventType && eventGridEventModel.Data == eventGridViewerEventModel.Data && + eventGridEventModel.EventType == eventGridViewerEventModel.EventType && eventGridEventModel.Data == eventGridViewerEventModel.Data.ToString() && eventGridEventModel.EventTime == eventGridViewerEventModel.EventTime); } } diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs index 7c706cb..6b242be 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs @@ -1,12 +1,13 @@ using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Adapters; using Blazor.EventGridViewer.Services.Interfaces; -using Microsoft.Azure.EventGrid.Models; +//using Microsoft.Azure.EventGrid.Models; using Moq; using Newtonsoft.Json; using System.Collections.Generic; using System.Linq; using Xunit; +using Azure.Messaging.EventGrid; namespace Blazor.EventGridViewer.Unit.Tests { @@ -51,10 +52,10 @@ public void EventGridSchemaAdapterConvertEventGridTest() // Assert Assert.True(model.Id == mockModel.Id && model.Subject == mockModel.Subject && - model.EventType == mockModel.EventType && model.EventTime == mockModel.EventTime.ToString("o")); + model.EventType == mockModel.EventType && model.EventTime == mockModel.EventTime); var data = JsonConvert.SerializeObject(mockModel, Formatting.Indented); - Assert.Equal(data, model.Data); + Assert.Equal(data, model.Data.ToString()); } /// @@ -78,7 +79,7 @@ public void EventGridSchemaAdapterConvertCloudEventTest() model.EventType == mockModel.Type && model.EventTime == mockModel.Time); var data = JsonConvert.SerializeObject(mockModel, Formatting.Indented); - Assert.Equal(data, model.Data); + Assert.Equal(data, model.Data.ToString()); } } } From f0ba3f0aabed83fbda2c38ea4b0966dd55449939 Mon Sep 17 00:00:00 2001 From: v-yilinhu Date: Tue, 17 May 2022 15:41:25 +0800 Subject: [PATCH 2/7] update core version --- .../Blazor.EventGridViewer.Core.csproj | 2 +- .../Blazor.EventGridViewer.ServerApp.csproj | 3 +-- .../Adapters/EventGridSchemaAdapter.cs | 1 - .../Blazor.EventGridViewer.Services.csproj | 3 +-- .../Blazor.EventGridViewer.Unit.Tests.csproj | 2 +- .../EventGridSchemaAdapterTests.cs | 1 - 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj index 546fc83..7f71acb 100644 --- a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj +++ b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj @@ -1,7 +1,7 @@  - net6.0 + netcoreapp3.1 diff --git a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj index 86f1ad5..bb3fed3 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj +++ b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj @@ -1,7 +1,7 @@  - net6.0 + netcoreapp3.1 aspnet-Blazor.EventGridViewer.ServerApp-5673166F-2442-4564-A540-4C06195A2FF8 0 @@ -10,7 +10,6 @@ - diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs index 8581fb5..43a1a8d 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs @@ -1,7 +1,6 @@ using Blazor.EventGridViewer.Core; using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Interfaces; -//using Microsoft.Azure.EventGrid.Models; using Newtonsoft.Json; using System; using System.Collections.Generic; diff --git a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj index 4049166..df564e9 100644 --- a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj +++ b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj @@ -1,7 +1,7 @@  - net6.0 + netcoreapp3.1 @@ -10,7 +10,6 @@ - diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj index 7b86879..050869d 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj +++ b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + netcoreapp3.1 diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs index 6b242be..6a1ac49 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs @@ -1,7 +1,6 @@ using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Adapters; using Blazor.EventGridViewer.Services.Interfaces; -//using Microsoft.Azure.EventGrid.Models; using Moq; using Newtonsoft.Json; using System.Collections.Generic; From 8dd6d1a35b51e28cf77819ffaa842d3031eea936 Mon Sep 17 00:00:00 2001 From: v-yilinhu Date: Tue, 17 May 2022 15:43:41 +0800 Subject: [PATCH 3/7] update core version --- .../Blazor.EventGridViewer.Core.csproj | 2 +- .../Blazor.EventGridViewer.ServerApp.csproj | 2 +- .../Blazor.EventGridViewer.Services.csproj | 2 +- .../Blazor.EventGridViewer.Unit.Tests.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj index 7f71acb..1e00b5c 100644 --- a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj +++ b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj index bb3fed3..159f88c 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj +++ b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 aspnet-Blazor.EventGridViewer.ServerApp-5673166F-2442-4564-A540-4C06195A2FF8 0 diff --git a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj index df564e9..cd5994b 100644 --- a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj +++ b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj index 050869d..8e02c54 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj +++ b/src/Blazor.EventGridViewer.Unit.Tests/Blazor.EventGridViewer.Unit.Tests.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net5.0 From 27d3dbe474852fc0467311fa6700e1f2d143ce11 Mon Sep 17 00:00:00 2001 From: v-yilinhu Date: Tue, 17 May 2022 17:45:30 +0800 Subject: [PATCH 4/7] update code --- .../Models/CloudEvent.cs | 2 +- .../Models/EventGridViewerEventModel.cs | 2 +- .../Adapters/EventGridEventModelAdapter.cs | 2 +- .../Adapters/EventGridSchemaAdapter.cs | 4 +-- src/Blazor.EventGridViewer.Unit.Tests/Data.cs | 26 ++----------------- .../EventGridSchemaAdapterTests.cs | 3 ++- 6 files changed, 9 insertions(+), 30 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs index 6c626dd..717c7e8 100644 --- a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs +++ b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs @@ -25,6 +25,6 @@ public class CloudEvent public DateTimeOffset Time { get; set; } [JsonProperty("data")] - public BinaryData Data { get; set; } + public object Data { get; set; } } } diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs index c501eff..4ddf711 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs @@ -18,7 +18,7 @@ public class EventGridViewerEventModel /// /// EventGrid Data /// - public BinaryData Data { get; set; } + public string Data { get; set; } /// /// EventGrid Subject /// diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs index b78e7ac..f1ab592 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridEventModelAdapter.cs @@ -21,7 +21,7 @@ public EventGridViewerEventModel Convert(EventGridEventModel t) EventGridViewerEventModel model = new EventGridViewerEventModel() { - Data = t.EventData, + Data = t.Data, EventType = t.EventType, Subject = t.Subject, Id = t.Id, diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs index 43a1a8d..a5e84a2 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs @@ -56,7 +56,7 @@ private List AdaptCloudEvent(string t) EventType = cloudEvent.Type, Subject = string.IsNullOrEmpty(cloudEvent.Subject) ? cloudEvent.Type : cloudEvent.Subject, Data = json, - EventData = cloudEvent.Data, + EventData = new BinaryData(cloudEvent.Data), EventTime = cloudEvent.Time }; models.Add(model); @@ -72,7 +72,7 @@ private List AdaptCloudEvent(string t) private List AdaptEventGridEvent(string t) { List models = new List(); - var eventGridEvents = JsonConvert.DeserializeObject>(t); + var eventGridEvents = EventGridEvent.ParseMany(new BinaryData(t)); foreach (var eventGridEvent in eventGridEvents) { diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs index cee5972..ee574a1 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs @@ -15,18 +15,7 @@ public static class Data public static string GetMockEventGridEventJson() { // Note: guids were generated with an online guid generator - string mockEventGridEvent = @"[{ - 'id' : 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', - 'topic':'subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', - 'subject':'EventGridSubscriptionValidation', - 'data': { - 'validationCode': '595c123c-0b91-4fa1-8b40-36f2e44194c9' - }, - 'eventType': 'Microsoft.EventGrid.SubscriptionValidationEvent', - 'eventTime': '2018-01-25T22:12:19.4556811Z', - 'metadataVersion': '1', - 'dataVersion': '1' -}]"; + string mockEventGridEvent = "[{\"id\": \"efdae305-d50f-49f6-a6ec-bd632d52bb3b\",\"topic\":\"subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\"subject\":\"EventGridSubscriptionValidation\",\"data\": {\"validationCode\": \"595c123c-0b91-4fa1-8b40-36f2e44194c9\"},\"eventType\": \"Microsoft.EventGrid.SubscriptionValidationEvent\",\"eventTime\": \"2018-01-25T22:12:19.4556811Z\",\"metadataVersion\": \"1\",\"dataVersion\": \"1\"}]"; return mockEventGridEvent; } @@ -37,18 +26,7 @@ public static string GetMockEventGridEventJson() public static string GetMockCloudEventJson() { // Note: guids were generated with an online guid generator - string mockCloudEvent = @"[{ - 'specversion' : '1.0', - 'type':'com.github.pull.create', - 'source':'https://github.com/cloudevents/spec/pull', - 'subject': '123', - 'id': 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', - 'time': '2018-01-25T22:12:19.4556811Z', - 'data': { - 'make': 'Ducati', - 'model':'Monster' - }, -}]"; + string mockCloudEvent = "{\"specversion\":\"1.0\",\"type\":\"com.github.pull.create\",\"source\":\"https://github.com/cloudevents/spec/pull\",\"subject\": \"123\",\"id\": \"efdae305-d50f-49f6-a6ec-bd632d52bb3b\",\"time\": \"2018-01-25T22:12:19.4556811Z\",\"data\": {\"make\": \"Ducati\",\"model\":\"Monster\"}}"; return mockCloudEvent; } diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs index 6a1ac49..854b55a 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs @@ -7,6 +7,7 @@ using System.Linq; using Xunit; using Azure.Messaging.EventGrid; +using Newtonsoft.Json.Linq; namespace Blazor.EventGridViewer.Unit.Tests { @@ -44,7 +45,7 @@ public void EventGridSchemaAdapterConvertEventGridTest() Mock mockEventGridIdentifySchemaService = new Mock(); mockEventGridIdentifySchemaService.Setup(s => s.Identify(json)).Returns(Core.EventGridSchemaType.EventGrid); IAdapter> adapter = new EventGridSchemaAdapter(mockEventGridIdentifySchemaService.Object); - var mockModel = JsonConvert.DeserializeObject>(json).FirstOrDefault(); + var mockModel = EventGridEvent.ParseMany(new System.BinaryData(json)).FirstOrDefault(); // Act var model = adapter.Convert(Data.GetMockEventGridEventJson()).FirstOrDefault(); From 2355dc5305717eb11078e310017a0ff5047901e5 Mon Sep 17 00:00:00 2001 From: v-yilinhu Date: Tue, 17 May 2022 18:18:24 +0800 Subject: [PATCH 5/7] update code --- .../Controllers/EventGridController.cs | 2 +- .../Shared/MainLayout.razor.cs | 2 +- src/Blazor.EventGridViewer.Unit.Tests/Data.cs | 14 +------------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs index 944ddb9..5ad1bae 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs @@ -75,7 +75,7 @@ public async Task Post() } } } - catch (Exception ex) + catch (Exception) { result = new StatusCodeResult(StatusCodes.Status500InternalServerError); } diff --git a/src/Blazor.EventGridViewer.ServerApp/Shared/MainLayout.razor.cs b/src/Blazor.EventGridViewer.ServerApp/Shared/MainLayout.razor.cs index 3df1c62..f5fd030 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Shared/MainLayout.razor.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Shared/MainLayout.razor.cs @@ -19,7 +19,7 @@ protected override async Task OnInitializedAsync() { await BootstrapCss.SetBootstrapCss(BOOTSTRAP_VERSION); } - catch (Exception ex) + catch (Exception) { _isServerSide = true; } diff --git a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs index ee574a1..1aeb65a 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/Data.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/Data.cs @@ -37,19 +37,7 @@ public static string GetMockCloudEventJson() public static string GetMockCloudEventExtraPropertiesJson() { // Note: guids were generated with an online guid generator - string mockCloudEventExtraProperties = @"[{ - 'specversion' : '1.0', - 'type':'com.github.pull.create', - 'source':'https://github.com/cloudevents/spec/pull', - 'subject': '123', - 'id': 'efdae305-d50f-49f6-a6ec-bd632d52bb3b', - 'time': '2018-01-25T22:12:19.4556811Z', - 'comexampleothervalue':'5', - 'data': { - 'make': 'Ducati', - 'model':'Monster' - } -}]"; + string mockCloudEventExtraProperties = "[{\"specversion\":\"1.0\",\"type\":\"com.github.pull.create\",\"source\":\"https://github.com/cloudevents/spec/pull\",\"subject\":\"123\",\"id\":\"efdae305-d50f-49f6-a6ec-bd632d52bb3b\",\"time\": \"2018-01-25T22:12:19.4556811Z\",\"comexampleothervalue\":\"5\",\"data\": {\"make\": \"Ducati\",\"model\":\"Monster\"}}]"; return mockCloudEventExtraProperties; } } From c2b5bda1a27e320e9428b40ae2a8555f3f44357e Mon Sep 17 00:00:00 2001 From: zedy Date: Mon, 5 Sep 2022 14:35:04 +0800 Subject: [PATCH 6/7] remove some invalid changes --- .../Blazor.EventGridViewer.Core.csproj | 3 +-- src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs | 2 +- .../Models/EventGridEventModel.cs | 4 ++-- .../Models/EventGridViewerEventModel.cs | 2 +- .../Blazor.EventGridViewer.ServerApp.csproj | 2 +- .../Controllers/EventGridController.cs | 5 ++--- .../Adapters/EventGridSchemaAdapter.cs | 2 +- .../Blazor.EventGridViewer.Services.csproj | 2 +- .../EventGridEventModelAdapterTests.cs | 3 +-- .../EventGridSchemaAdapterTests.cs | 8 ++++---- 10 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj index 1e00b5c..131a85e 100644 --- a/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj +++ b/src/Blazor.EventGridViewer.Core/Blazor.EventGridViewer.Core.csproj @@ -5,9 +5,8 @@ - + - diff --git a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs index 717c7e8..40ec229 100644 --- a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs +++ b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs @@ -22,7 +22,7 @@ public class CloudEvent public string Id { get; set; } [JsonProperty("time")] - public DateTimeOffset Time { get; set; } + public string Time { get; set; } [JsonProperty("data")] public object Data { get; set; } diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs index 3ac9332..728712c 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs @@ -26,11 +26,11 @@ public class EventGridEventModel /// /// EventGrid Data /// - public BinaryData EventData { get; set; } + public object EventData { get; set; } /// /// EventGrid Event Time /// - public DateTimeOffset EventTime { get; set; } + public string EventTime { get; set; } /// /// Data Version /// diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs index 4ddf711..3bb64d5 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridViewerEventModel.cs @@ -26,7 +26,7 @@ public class EventGridViewerEventModel /// /// EventGrid Event Time /// - public DateTimeOffset EventTime { get; set; } + public string EventTime { get; set; } /// /// Unique Id for EventGridViewer Event /// diff --git a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj index 159f88c..8463178 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj +++ b/src/Blazor.EventGridViewer.ServerApp/Blazor.EventGridViewer.ServerApp.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs index 5ad1bae..200db1a 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs @@ -10,7 +10,6 @@ using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using Azure.Messaging.EventGrid; -using Azure.Messaging.EventGrid.Models; using Azure.Messaging.EventGrid.SystemEvents; namespace Blazor.EventGridViewer.ServerApp.Controllers @@ -60,9 +59,9 @@ public async Task Post() { EventGridEvent eventGrid = new EventGridEvent(model.Subject, model.EventType, model.DataVersion, model.EventData); // EventGrid validation message - if (eventGrid.TryGetSystemEventData(out object systemEvent)) + if (model.EventType == "SubscriptionValidationEventData") { - var eventData = ((JObject)systemEvent).ToObject(); + var eventData = ((JObject)(model.EventType)).ToObject(); var responseData = new SubscriptionValidationResponse() { ValidationResponse = eventData.ValidationCode diff --git a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs index a5e84a2..3a9662f 100644 --- a/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs +++ b/src/Blazor.EventGridViewer.Services/Adapters/EventGridSchemaAdapter.cs @@ -84,7 +84,7 @@ private List AdaptEventGridEvent(string t) Subject = string.IsNullOrEmpty(eventGridEvent.Subject) ? eventGridEvent.EventType : eventGridEvent.Subject, Data = json, EventData = eventGridEvent.Data, - EventTime = eventGridEvent.EventTime // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netcore-3.1 + EventTime = eventGridEvent.EventTime.ToString("o") // https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netcore-3.1 }; models.Add(model); } diff --git a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj index cd5994b..2e57e0f 100644 --- a/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj +++ b/src/Blazor.EventGridViewer.Services/Blazor.EventGridViewer.Services.csproj @@ -9,7 +9,7 @@ - + diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs index 4a66f9b..c7d075a 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridEventModelAdapterTests.cs @@ -1,7 +1,6 @@ using Blazor.EventGridViewer.Core.Models; using Blazor.EventGridViewer.Services.Adapters; using Blazor.EventGridViewer.Services.Interfaces; -using System; using Xunit; namespace Blazor.EventGridViewer.Unit.Tests @@ -42,7 +41,7 @@ public void EventGridEventModelAdapterConvertCanConvertEventGridEventModel() // Assert Assert.True(eventGridEventModel.Id == eventGridViewerEventModel.Id && eventGridEventModel.Subject == eventGridViewerEventModel.Subject && - eventGridEventModel.EventType == eventGridViewerEventModel.EventType && eventGridEventModel.Data == eventGridViewerEventModel.Data.ToString() && + eventGridEventModel.EventType == eventGridViewerEventModel.EventType && eventGridEventModel.Data == eventGridViewerEventModel.Data && eventGridEventModel.EventTime == eventGridViewerEventModel.EventTime); } } diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs index 854b55a..e7c8524 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs @@ -45,17 +45,17 @@ public void EventGridSchemaAdapterConvertEventGridTest() Mock mockEventGridIdentifySchemaService = new Mock(); mockEventGridIdentifySchemaService.Setup(s => s.Identify(json)).Returns(Core.EventGridSchemaType.EventGrid); IAdapter> adapter = new EventGridSchemaAdapter(mockEventGridIdentifySchemaService.Object); - var mockModel = EventGridEvent.ParseMany(new System.BinaryData(json)).FirstOrDefault(); + var mockModel = JsonConvert.DeserializeObject>(json).FirstOrDefault(); // Act var model = adapter.Convert(Data.GetMockEventGridEventJson()).FirstOrDefault(); // Assert Assert.True(model.Id == mockModel.Id && model.Subject == mockModel.Subject && - model.EventType == mockModel.EventType && model.EventTime == mockModel.EventTime); + model.EventType == mockModel.EventType && model.EventTime == mockModel.EventTime.ToString("o")); var data = JsonConvert.SerializeObject(mockModel, Formatting.Indented); - Assert.Equal(data, model.Data.ToString()); + Assert.Equal(data, model.Data); } /// @@ -79,7 +79,7 @@ public void EventGridSchemaAdapterConvertCloudEventTest() model.EventType == mockModel.Type && model.EventTime == mockModel.Time); var data = JsonConvert.SerializeObject(mockModel, Formatting.Indented); - Assert.Equal(data, model.Data.ToString()); + Assert.Equal(data, model.Data); } } } From 7fbb390b463a638c9cae987e774163006039ee9a Mon Sep 17 00:00:00 2001 From: zedy Date: Mon, 5 Sep 2022 14:42:58 +0800 Subject: [PATCH 7/7] fix invalid reference --- src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs | 1 - src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs | 4 +--- .../Controllers/EventGridController.cs | 2 +- src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor | 2 +- .../Interfaces/IEventGridService.cs | 3 +-- .../EventGridSchemaAdapterTests.cs | 1 - 6 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs index 40ec229..b8aa9c7 100644 --- a/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs +++ b/src/Blazor.EventGridViewer.Core/Models/CloudEvent.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using System; namespace Blazor.EventGridViewer.Core.Models { diff --git a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs index 728712c..0f62173 100644 --- a/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs +++ b/src/Blazor.EventGridViewer.Core/Models/EventGridEventModel.cs @@ -1,6 +1,4 @@ -using System; - -namespace Blazor.EventGridViewer.Core.Models +namespace Blazor.EventGridViewer.Core.Models { /// /// Class used as a model for EventGrid Events diff --git a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs index 200db1a..7e182e7 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs +++ b/src/Blazor.EventGridViewer.ServerApp/Controllers/EventGridController.cs @@ -61,7 +61,7 @@ public async Task Post() // EventGrid validation message if (model.EventType == "SubscriptionValidationEventData") { - var eventData = ((JObject)(model.EventType)).ToObject(); + var eventData = ((JObject)(model.EventData)).ToObject(); var responseData = new SubscriptionValidationResponse() { ValidationResponse = eventData.ValidationCode diff --git a/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor b/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor index eeb816a..2bfd44a 100644 --- a/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor +++ b/src/Blazor.EventGridViewer.ServerApp/Pages/Index.razor @@ -27,7 +27,7 @@
@model.Data
- +
diff --git a/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs b/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs index 40b54de..38cc61c 100644 --- a/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs +++ b/src/Blazor.EventGridViewer.Services/Interfaces/IEventGridService.cs @@ -1,5 +1,4 @@ -using Azure.Messaging.EventGrid; -using Blazor.EventGridViewer.Core.CustomEventArgs; +using Blazor.EventGridViewer.Core.CustomEventArgs; using Blazor.EventGridViewer.Core.Models; using System; diff --git a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs index e7c8524..572b374 100644 --- a/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs +++ b/src/Blazor.EventGridViewer.Unit.Tests/EventGridSchemaAdapterTests.cs @@ -7,7 +7,6 @@ using System.Linq; using Xunit; using Azure.Messaging.EventGrid; -using Newtonsoft.Json.Linq; namespace Blazor.EventGridViewer.Unit.Tests {