microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
Tests/Microsoft.Teams.Api.Tests/Entities/ProductInfoEntityTests.cs
95lines · modecode
| 1 | using System.Text.Json; |
| 2 | |
| 3 | using Microsoft.Teams.Api.Entities; |
| 4 | |
| 5 | namespace Microsoft.Teams.Api.Tests.Entities; |
| 6 | |
| 7 | public class ProductInfoEntityTests |
| 8 | { |
| 9 | [Fact] |
| 10 | public void ProductInfoEntity_JsonSerialize() |
| 11 | { |
| 12 | var entity = new ProductInfoEntity() |
| 13 | { |
| 14 | Id = "COPILOT" |
| 15 | }; |
| 16 | |
| 17 | var json = JsonSerializer.Serialize(entity, new JsonSerializerOptions() |
| 18 | { |
| 19 | WriteIndented = true, |
| 20 | IndentSize = 2, |
| 21 | DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull |
| 22 | }); |
| 23 | |
| 24 | Assert.Equal(File.ReadAllText( |
| 25 | @"../../../Json/Entities/ProductInfoEntity.json" |
| 26 | ), json); |
| 27 | } |
| 28 | |
| 29 | [Fact] |
| 30 | public void ProductInfoEntity_JsonSerialize_Derived() |
| 31 | { |
| 32 | ProductInfoEntity entity = new ProductInfoEntity() |
| 33 | { |
| 34 | Id = "COPILOT" |
| 35 | }; |
| 36 | |
| 37 | var json = JsonSerializer.Serialize(entity, new JsonSerializerOptions() |
| 38 | { |
| 39 | WriteIndented = true, |
| 40 | IndentSize = 2, |
| 41 | DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull |
| 42 | }); |
| 43 | |
| 44 | Assert.Equal(File.ReadAllText( |
| 45 | @"../../../Json/Entities/ProductInfoEntity.json" |
| 46 | ), json); |
| 47 | } |
| 48 | |
| 49 | [Fact] |
| 50 | public void ProductInfoEntity_JsonSerialize_Interface_Derived() |
| 51 | { |
| 52 | Entity entity = new ProductInfoEntity() |
| 53 | { |
| 54 | Id = "COPILOT" |
| 55 | }; |
| 56 | |
| 57 | var json = JsonSerializer.Serialize(entity, new JsonSerializerOptions() |
| 58 | { |
| 59 | WriteIndented = true, |
| 60 | IndentSize = 2, |
| 61 | DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull |
| 62 | }); |
| 63 | |
| 64 | Assert.Equal(File.ReadAllText( |
| 65 | @"../../../Json/Entities/ProductInfoEntity.json" |
| 66 | ), json); |
| 67 | } |
| 68 | |
| 69 | [Fact] |
| 70 | public void ProductInfoEntity_JsonDeserialize() |
| 71 | { |
| 72 | var json = File.ReadAllText(@"../../../Json/Entities/ProductInfoEntity.json"); |
| 73 | var entity = JsonSerializer.Deserialize<ProductInfoEntity>(json); |
| 74 | |
| 75 | var expected = new ProductInfoEntity() |
| 76 | { |
| 77 | Id = "COPILOT" |
| 78 | }; |
| 79 | |
| 80 | Assert.Equivalent(expected, entity); |
| 81 | } |
| 82 | |
| 83 | [Fact] |
| 84 | public void ProductInfoEntity_JsonDeserialize_Derived() |
| 85 | { |
| 86 | var json = File.ReadAllText(@"../../../Json/Entities/ProductInfoEntity.json"); |
| 87 | var entity = JsonSerializer.Deserialize<Entity>(json); |
| 88 | var expected = new ProductInfoEntity() |
| 89 | { |
| 90 | Id = "COPILOT" |
| 91 | }; |
| 92 | |
| 93 | Assert.Equivalent(expected, entity); |
| 94 | } |
| 95 | } |