Skip to content

Commit fe0ffad

Browse files
author
Andrew Omondi
committed
Update planner task
1 parent c70662e commit fe0ffad

2 files changed

Lines changed: 114 additions & 2 deletions

File tree

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
using Microsoft.Kiota.Abstractions.Serialization;
6+
using Microsoft.Kiota.Abstractions.Store;
7+
using System;
8+
using System.Collections.Generic;
9+
10+
namespace Microsoft.Graph.Models;
11+
12+
public class PlannerAssignment: IAdditionalDataHolder, IBackedModel, IParsable
13+
{
14+
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
15+
public IDictionary<string, object> AdditionalData {
16+
get { return BackingStore?.Get<IDictionary<string, object>>("additionalData"); }
17+
set { BackingStore?.Set("additionalData", value); }
18+
}
19+
/// <summary>Stores model information.</summary>
20+
public IBackingStore BackingStore { get; private set; }
21+
/// <summary>The OdataType property</summary>
22+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
23+
#nullable enable
24+
public string? OdataType {
25+
get { return BackingStore?.Get<string?>("@odata.type"); }
26+
set { BackingStore?.Set("@odata.type", value); }
27+
}
28+
#nullable restore
29+
#else
30+
public string OdataType {
31+
get { return BackingStore?.Get<string>("@odata.type"); }
32+
set { BackingStore?.Set("@odata.type", value); }
33+
}
34+
#endif
35+
/// <summary>The OdataType property</summary>
36+
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
37+
#nullable enable
38+
public string? OrderHint {
39+
get { return BackingStore?.Get<string?>("orderHint"); }
40+
set { BackingStore?.Set("orderHint", value); }
41+
}
42+
#nullable restore
43+
#else
44+
public string OrderHint {
45+
get { return BackingStore?.Get<string>("orderHint"); }
46+
set { BackingStore?.Set("orderHint", value); }
47+
}
48+
#endif
49+
/// <summary>
50+
/// Instantiates a new auditActivityInitiator and sets the default values.
51+
/// </summary>
52+
public PlannerAssignment() {
53+
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
54+
AdditionalData = new Dictionary<string, object>();
55+
OdataType = "#microsoft.graph.plannerAssignment";
56+
OrderHint = "!";
57+
}
58+
/// <summary>
59+
/// Creates a new instance of the appropriate class based on discriminator value
60+
/// </summary>
61+
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
62+
public static PlannerAssignment CreateFromDiscriminatorValue(IParseNode parseNode) {
63+
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
64+
return new PlannerAssignment();
65+
}
66+
/// <summary>
67+
/// The deserialization information for the current model
68+
/// </summary>
69+
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
70+
return new Dictionary<string, Action<IParseNode>> {
71+
{"@odata.type", n => { OdataType = n.GetStringValue(); } },
72+
{"orderHint", n => { OrderHint = n.GetStringValue(); } },
73+
};
74+
}
75+
/// <summary>
76+
/// Serializes information the current object
77+
/// </summary>
78+
/// <param name="writer">Serialization writer to use to serialize this model</param>
79+
public void Serialize(ISerializationWriter writer) {
80+
_ = writer ?? throw new ArgumentNullException(nameof(writer));
81+
writer.WriteStringValue("@odata.type", OdataType);
82+
writer.WriteStringValue("orderHint", OrderHint);
83+
writer.WriteAdditionalData(AdditionalData);
84+
}
85+
}

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

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ------------------------------------------------------------------------------
1+
// ------------------------------------------------------------------------------
22
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
33
// ------------------------------------------------------------------------------
44

@@ -9,6 +9,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Models
99
using Microsoft.Graph.Models;
1010
using Microsoft.Kiota.Abstractions;
1111
using Microsoft.Kiota.Serialization.Json;
12+
using System.Collections.Generic;
1213
using System.IO;
1314
using System.Text;
1415

@@ -159,7 +160,7 @@ public void SerializeAndDeserializeKnownEnumValue()
159160
Assert.Null(itemBody.AdditionalData);
160161
}
161162

162-
[Fact(Skip = "TODO fix pending odata.type bug")]
163+
[Fact]
163164
public void SerializeDateValue()
164165
{
165166
var now = DateTimeOffset.UtcNow;
@@ -198,5 +199,31 @@ public void TestEtagHelper()
198199
Assert.Equal(userId, user.Id);
199200
//Assert.Equal(testEtag, user.GetEtag());
200201
}
202+
[Fact]
203+
public void TestPlannerAssigmentSerialization()
204+
{
205+
var planTask = new PlannerTask
206+
{
207+
PlanId = "PLAN_ID",
208+
BucketId = "BUCKET_ID",
209+
Title = "My Planner Task",
210+
Assignments = new PlannerAssignments
211+
{
212+
AdditionalData = new Dictionary<string, object>
213+
{
214+
{"USER_ID", new PlannerAssignment()}
215+
}
216+
}
217+
};
218+
219+
string expectedSerializedString = "{\"assignments\":{\"USER_ID\":{\"@odata.type\":\"#microsoft.graph.plannerAssignment\",\"orderHint\":\"!\"}},\"bucketId\":\"BUCKET_ID\",\"planId\":\"PLAN_ID\",\"title\":\"My Planner Task\"}";
220+
using var jsonSerializerWriter = new JsonSerializationWriter();
221+
jsonSerializerWriter.WriteObjectValue(string.Empty, planTask);
222+
var serializedStream = jsonSerializerWriter.GetSerializedContent();
223+
224+
// Assert
225+
var streamReader = new StreamReader(serializedStream);
226+
Assert.Equal(expectedSerializedString, streamReader.ReadToEnd());
227+
}
201228
}
202229
}

0 commit comments

Comments
 (0)