Skip to content

Commit 0ae8bd2

Browse files
author
Bert Jansen
committed
Merge of #1003. Thanks @quails4Eva
2 parents 1aba790 + 281de1f commit 0ae8bd2

28 files changed

+1369
-2058
lines changed

src/lib/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
66

77
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
88

9+
## [Unreleased]
10+
11+
### Added
12+
13+
### Changed
14+
15+
- Removed the dependency on Microsof.Graph packages #1003 [quails4Eva]
16+
917
## [1.18.0]
1018

1119
### Added
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Text.Json;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using PnP.Framework.Entities;
8+
using PnP.Framework.Graph;
9+
10+
namespace PnP.Framework.Test.Graph
11+
{
12+
[TestClass]
13+
public class UnifiedGroupsUtilityTests
14+
{
15+
[TestMethod]
16+
public void GetUnifiedGroupMembers_WhenCalled_ShouldReturnData()
17+
{
18+
// Arrange
19+
TestCommon.RegisterPnPHttpClientMock();
20+
//var fakeHandler = new MockHttpHandler("");
21+
22+
// Act
23+
var results = UnifiedGroupsUtility.GetUnifiedGroupMembers(
24+
new UnifiedGroupEntity() { GroupId = "abc", },
25+
"testt"
26+
);
27+
28+
// Assert
29+
Assert.IsNotNull(results);
30+
Assert.IsTrue(results.Count > 1);
31+
32+
AssertAllPropertiesHaveBeenAssigned(results);
33+
}
34+
35+
private static void AssertAllPropertiesHaveBeenAssigned<T>(List<T> results)
36+
{
37+
foreach (PropertyInfo pi in typeof(T).GetProperties())
38+
{
39+
Assert.IsTrue(
40+
results.Any(r =>
41+
pi.GetValue(r, null) != (pi.PropertyType.IsValueType ? Activator.CreateInstance(pi.PropertyType) : null)
42+
)
43+
);
44+
}
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"Url": "https://graph.microsoft.com/v1.0/groups/abc/members/microsoft.graph.user",
4+
"Body": "",
5+
"Content": "{\r\n \"@odata.context\": \"https:\/\/graph.microsoft.com\/v1.0\/$metadata#directoryObjects\",\r\n \"value\": [\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"87d349ed-44d7-43e1-9a83-5f2406dee5bd\",\r\n \"businessPhones\": [\r\n \"+1 425 555 0109\"\r\n ],\r\n \"displayName\": \"Adele Vance\",\r\n \"givenName\": \"Adele\",\r\n \"jobTitle\": \"Product Marketing Manager\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": \"1234\",\r\n \"officeLocation\": \"18\/2111\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Vance\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"626cbf8c-5dde-46b0-8385-9e40d64736fe\",\r\n \"businessPhones\": [\r\n \"+1 502 555 0102\"\r\n ],\r\n \"displayName\": \"Johanna Lorenz\",\r\n \"givenName\": \"Johanna\",\r\n \"jobTitle\": \"CVP Engineering\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"23\/2102\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Lorenz\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"40079818-3808-4585-903b-02605f061225\",\r\n \"businessPhones\": [\r\n \"+1 502 555 0144\"\r\n ],\r\n \"displayName\": \"Patti Fernandez\",\r\n \"givenName\": \"Patti\",\r\n \"jobTitle\": \"President\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"15\/1102\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Fernandez\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"074e56ea-0b50-4461-89e5-c67ae14a2c0b\",\r\n \"businessPhones\": [\r\n \"+1 913 555 0101\"\r\n ],\r\n \"displayName\": \"Lee Gu\",\r\n \"givenName\": \"Lee\",\r\n \"jobTitle\": \"CVP Research & Development\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"23\/3101\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Gu\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"16cfe710-1625-4806-9990-91b8f0afee35\",\r\n \"businessPhones\": [\r\n \"+1 205 555 0103\"\r\n ],\r\n \"displayName\": \"Enrico Cattaneo\",\r\n \"givenName\": \"Enrico\",\r\n \"jobTitle\": \"Attorney\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"14\/1102\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Cattaneo\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"089a6bb8-e8cb-492c-aa41-c078aa0b5120\",\r\n \"businessPhones\": [\r\n \"+1 206 555 0105\"\r\n ],\r\n \"displayName\": \"Nestor Wilke\",\r\n \"givenName\": \"Nestor\",\r\n \"jobTitle\": \"CVP Operations\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"36\/2121\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Wilke\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"2804bc07-1e1f-4938-9085-ce6d756a32d2\",\r\n \"businessPhones\": [\r\n \"+81 345550115\"\r\n ],\r\n \"displayName\": \"Emily Braun\",\r\n \"givenName\": \"Emily\",\r\n \"jobTitle\": \"Budget Analyst\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"97\/2302\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Braun\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"b66ecf79-a093-4d51-86e0-efcc4531f37a\",\r\n \"businessPhones\": [\r\n \"+1 858 555 0111\"\r\n ],\r\n \"displayName\": \"Christie Cline\",\r\n \"givenName\": \"Christie\",\r\n \"jobTitle\": \"Sr. VP Sales & Marketing\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"131\/2105\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Cline\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"8b209ac8-08ff-4ef1-896d-3b9fde0bbf04\",\r\n \"businessPhones\": [\r\n \"+1 980 555 0101\"\r\n ],\r\n \"displayName\": \"Joni Sherman\",\r\n \"givenName\": \"Joni\",\r\n \"jobTitle\": \"Paralegal\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"20\/1109\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Sherman\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"4782e723-f4f4-4af3-a76e-25e3bab0d896\",\r\n \"businessPhones\": [\r\n \"+1 858 555 0110\"\r\n ],\r\n \"displayName\": \"Alex Wilber\",\r\n \"givenName\": \"Alex\",\r\n \"jobTitle\": \"Marketing Assistant\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"131\/1104\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Wilber\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"08fa38e4-cbfa-4488-94ed-c834da6539df\",\r\n \"businessPhones\": [\r\n \"+1 858 555 0109\"\r\n ],\r\n \"displayName\": \"Miriam Graham\",\r\n \"givenName\": \"Miriam\",\r\n \"jobTitle\": \"VP Marketing\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"131\/2103\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Graham\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"24fcbca3-c3e2-48bf-9ffc-c7f81b81483d\",\r\n \"businessPhones\": [\r\n \"+1 205 555 0108\"\r\n ],\r\n \"displayName\": \"Diego Siciliani\",\r\n \"givenName\": \"Diego\",\r\n \"jobTitle\": \"CVP Finance\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"14\/1108\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Siciliani\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"2ed03dfd-01d8-4005-a9ef-fa8ee546dc6c\",\r\n \"businessPhones\": [\r\n \"+1 918 555 0107\"\r\n ],\r\n \"displayName\": \"Lidia Holloway\",\r\n \"givenName\": \"Lidia\",\r\n \"jobTitle\": \"Product Manager\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"20\/2107\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Holloway\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"df043ff1-49d5-414e-86a4-0c7f239c36cf\",\r\n \"businessPhones\": [\r\n \"+1 309 555 0104\"\r\n ],\r\n \"displayName\": \"Grady Archie\",\r\n \"givenName\": \"Grady\",\r\n \"jobTitle\": \"CVP Legal\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"19\/2109\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Archie\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"ec63c778-24e1-4240-bea3-d12a167d5232\",\r\n \"businessPhones\": [\r\n \"+20 255501070\"\r\n ],\r\n \"displayName\": \"Pradeep Gupta\",\r\n \"givenName\": \"Pradeep\",\r\n \"jobTitle\": \"Accountant II\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"98\/2202\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Gupta\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"48d31887-5fad-4d73-a9f5-3c356e68a038\",\r\n \"businessPhones\": [\r\n \"+1 412 555 0109\"\r\n ],\r\n \"displayName\": \"Megan Bowen\",\r\n \"givenName\": \"Megan\",\r\n \"jobTitle\": \"Auditor\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"12\/1110\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Bowen\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"e8a02cc7-df4d-4778-956d-784cc9506e5a\",\r\n \"businessPhones\": [\r\n \"+1 918 555 0104\"\r\n ],\r\n \"displayName\": \"Lynne Robbins\",\r\n \"givenName\": \"Lynne\",\r\n \"jobTitle\": \"Product Manager\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"20\/1104\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Robbins\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"c8913c86-ceea-4d39-b1ea-f63a5b675166\",\r\n \"businessPhones\": [\r\n \"+1 954 555 0118\"\r\n ],\r\n \"displayName\": \"Henrietta Mueller\",\r\n \"givenName\": \"Henrietta\",\r\n \"jobTitle\": \"Marketing Assistant\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"18\/1106\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Mueller\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n },\r\n {\r\n \"@odata.type\": \"#microsoft.graph.user\",\r\n \"id\": \"e3d0513b-449e-4198-ba6f-bd97ae7cae85\",\r\n \"businessPhones\": [\r\n \"+1 918 555 0101\"\r\n ],\r\n \"displayName\": \"Isaiah Langer\",\r\n \"givenName\": \"Isaiah\",\r\n \"jobTitle\": \"Web Marketing Manager\",\r\n \"mail\": \"[email protected]\",\r\n \"mobilePhone\": null,\r\n \"officeLocation\": \"20\/1101\",\r\n \"preferredLanguage\": \"en-US\",\r\n \"surname\": \"Langer\",\r\n \"userPrincipalName\": \"[email protected]\"\r\n }\r\n ]\r\n}"
6+
}
7+
]
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Text.Json;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using PnP.Framework.Entities;
8+
using PnP.Framework.Graph;
9+
10+
namespace PnP.Framework.Test.Graph
11+
{
12+
[TestClass]
13+
public class UsersUtilityTests
14+
{
15+
[TestMethod]
16+
public void ListUsers_WhenCalled_ShouldReturnData()
17+
{
18+
// Arrange
19+
TestCommon.RegisterPnPHttpClientMock();
20+
21+
// Act
22+
var results = UsersUtility.ListUsers(
23+
"123",
24+
new[] {"postalCode"}
25+
);
26+
27+
// Assert
28+
Assert.IsNotNull(results);
29+
Assert.IsTrue(results.Count > 1);
30+
31+
AssertAllPropertiesHaveBeenAssigned(results);
32+
}
33+
34+
private static void AssertAllPropertiesHaveBeenAssigned<T>(List<T> results)
35+
{
36+
foreach (PropertyInfo pi in typeof(T).GetProperties())
37+
{
38+
Assert.IsTrue(
39+
results.Any(r =>
40+
pi.GetValue(r, null) != (pi.PropertyType.IsValueType ? Activator.CreateInstance(pi.PropertyType) : null)
41+
),
42+
pi.Name
43+
);
44+
}
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)