Skip to content

Commit 9e840d3

Browse files
author
Andrew Omondi
committed
Fix for initialization of ChangeNotificationCollection model
1 parent 4c556b9 commit 9e840d3

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/Microsoft.Graph/Extensions/ChangeNotificationCollection.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ namespace Microsoft.Graph.Models {
99
public class ChangeNotificationCollection : IAdditionalDataHolder,IBackedModel, IParsable {
1010
/// <summary>Stores model information.</summary>
1111
public IBackingStore BackingStore { get; private set; }
12+
13+
/// <summary>
14+
/// Instantiates a new ChangeNotificationCollection and sets the default values.
15+
/// </summary>
16+
public ChangeNotificationCollection() {
17+
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
18+
AdditionalData = new Dictionary<string, object>();
19+
}
20+
1221
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
1322
public IDictionary<string, object> AdditionalData {
1423
get { return BackingStore?.Get<IDictionary<string, object>>("additionalData"); }

tests/Microsoft.Graph.DotnetCore.Test/Models/ModelSerializationTests.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,41 @@ public void TestPlannerAssigmentSerialization()
225225
var streamReader = new StreamReader(serializedStream);
226226
Assert.Equal(expectedSerializedString, streamReader.ReadToEnd());
227227
}
228+
229+
[Fact]
230+
public void TestChangeNoticationCollectionDeserialization()
231+
{
232+
var json = @"{
233+
""value"": [
234+
{
235+
""changeType"": ""updated"",
236+
""subscriptionId"": ""c224ac82-d3f3-4079-80ed-b6cd355e0f56"",
237+
""resource"": ""external"",
238+
""clientState"": null,
239+
""resourceData"": {
240+
""@odata.type"": ""#Microsoft.Graph.connector"",
241+
""@odata.id"": ""external"",
242+
""id"": ""cf6c33ae-e462-41c8-928b-88a8dd410f23"",
243+
""state"": ""enabled"",
244+
""connectorsTicket"": ""eyJhbGciOiJIU...""
245+
},
246+
""subscriptionExpirationDateTime"": ""2023-09-20T20:39:46.8577199+00:00"",
247+
""tenantId"": ""cf6c33ae-e462-41c8-928b-88a8dd410f23""
248+
}
249+
],
250+
""validationTokens"": [
251+
""eyJ0eXAiOiJKV1...""
252+
]
253+
}";
254+
255+
using var memStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json));
256+
var parseNode = new JsonParseNodeFactory().GetRootParseNode("application/json", memStream);
257+
var changeNotifications = parseNode.GetObjectValue(ChangeNotificationCollection.CreateFromDiscriminatorValue);
258+
259+
Assert.NotNull(changeNotifications.Value);
260+
Assert.Single(changeNotifications.Value);
261+
Assert.NotNull(changeNotifications.ValidationTokens);
262+
Assert.Single(changeNotifications.ValidationTokens);
263+
}
228264
}
229265
}

0 commit comments

Comments
 (0)