Skip to content

Commit

Permalink
Adds planner assignment model
Browse files Browse the repository at this point in the history
  • Loading branch information
andrueastman committed Mar 22, 2023
1 parent 5e91226 commit f1a902e
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
85 changes: 85 additions & 0 deletions src/Microsoft.Graph/Extensions/PlannerAssignment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

using Microsoft.Kiota.Abstractions.Serialization;
using Microsoft.Kiota.Abstractions.Store;
using System;
using System.Collections.Generic;

namespace Microsoft.Graph.Beta.Models;

public class PlannerAssignment: IAdditionalDataHolder, IBackedModel, IParsable
{
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
public IDictionary<string, object> AdditionalData {
get { return BackingStore?.Get<IDictionary<string, object>>("additionalData"); }
set { BackingStore?.Set("additionalData", value); }
}
/// <summary>Stores model information.</summary>
public IBackingStore BackingStore { get; private set; }
/// <summary>The OdataType property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? OdataType {
get { return BackingStore?.Get<string?>("@odata.type"); }
set { BackingStore?.Set("@odata.type", value); }
}
#nullable restore
#else
public string OdataType {
get { return BackingStore?.Get<string>("@odata.type"); }
set { BackingStore?.Set("@odata.type", value); }
}
#endif
/// <summary>The OdataType property</summary>
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
#nullable enable
public string? OrderHint {
get { return BackingStore?.Get<string?>("orderHint"); }
set { BackingStore?.Set("orderHint", value); }
}
#nullable restore
#else
public string OrderHint {
get { return BackingStore?.Get<string>("orderHint"); }
set { BackingStore?.Set("orderHint", value); }
}
#endif
/// <summary>
/// Instantiates a new auditActivityInitiator and sets the default values.
/// </summary>
public PlannerAssignment() {
BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore();
AdditionalData = new Dictionary<string, object>();
OdataType = "#microsoft.graph.plannerAssignment";
OrderHint = "!";
}
/// <summary>
/// Creates a new instance of the appropriate class based on discriminator value
/// </summary>
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
public static PlannerAssignment CreateFromDiscriminatorValue(IParseNode parseNode) {
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
return new PlannerAssignment();
}
/// <summary>
/// The deserialization information for the current model
/// </summary>
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
return new Dictionary<string, Action<IParseNode>> {
{"@odata.type", n => { OdataType = n.GetStringValue(); } },
{"orderHint", n => { OrderHint = n.GetStringValue(); } },
};
}
/// <summary>
/// Serializes information the current object
/// </summary>
/// <param name="writer">Serialization writer to use to serialize this model</param>
public void Serialize(ISerializationWriter writer) {
_ = writer ?? throw new ArgumentNullException(nameof(writer));
writer.WriteStringValue("@odata.type", OdataType);
writer.WriteStringValue("orderHint", OrderHint);
writer.WriteAdditionalData(AdditionalData);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Graph.DotnetCore.Test.Models
using Microsoft.Graph.Beta.Models;
using Microsoft.Kiota.Abstractions;
using Microsoft.Kiota.Serialization.Json;
using System.Collections.Generic;
using System.IO;
using System.Text;

Expand Down Expand Up @@ -159,7 +160,6 @@ public void SerializeAndDeserializeKnownEnumValue()
Assert.Null(itemBody.AdditionalData);
}

[Fact(Skip = "TODO fix pending odata.type bug")]
public void SerializeDateValue()
{
var now = DateTimeOffset.UtcNow;
Expand Down Expand Up @@ -198,5 +198,31 @@ public void TestEtagHelper()
Assert.Equal(userId, user.Id);
//Assert.Equal(testEtag, user.GetEtag());
}
[Fact]
public void TestPlannerAssigmentSerialization()
{
var planTask = new PlannerTask
{
PlanId = "PLAN_ID",
BucketId = "BUCKET_ID",
Title = "My Planner Task",
Assignments = new PlannerAssignments
{
AdditionalData = new Dictionary<string, object>
{
{"USER_ID", new PlannerAssignment()}
}
}
};

string expectedSerializedString = "{\"assignments\":{\"USER_ID\":{\"@odata.type\":\"#microsoft.graph.plannerAssignment\",\"orderHint\":\"!\"}},\"bucketId\":\"BUCKET_ID\",\"planId\":\"PLAN_ID\",\"title\":\"My Planner Task\"}";
using var jsonSerializerWriter = new JsonSerializationWriter();
jsonSerializerWriter.WriteObjectValue(string.Empty, planTask);
var serializedStream = jsonSerializerWriter.GetSerializedContent();

// Assert
var streamReader = new StreamReader(serializedStream);
Assert.Equal(expectedSerializedString, streamReader.ReadToEnd());
}
}
}

0 comments on commit f1a902e

Please sign in to comment.