forked from pnp/pnpframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuiltInFieldIdTests.cs
53 lines (44 loc) · 1.62 KB
/
BuiltInFieldIdTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Linq;
using System.Reflection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PnP.Framework.Enums;
namespace PnP.Framework.Test.Framework.Functional
{
/// <summary>
/// Test cases for checking the functionality of BuiltInFieldId
/// </summary>
[TestClass]
public class BuiltInFieldIdTests
{
[TestMethod]
public void KnownBuiltInFieldCanBeFound()
{
var knownExistingId = BuiltInFieldId.ContentTypeId;
var actual = BuiltInFieldId.Contains(knownExistingId);
Assert.AreEqual(true, actual);
}
[TestMethod]
public void KnownNotBuiltInFieldCanNotBeFound()
{
var knownNonExistingId = new Guid("11111111-1111-1111-1111-111111111111");
var actual = BuiltInFieldId.Contains(knownNonExistingId);
Assert.AreEqual(false, actual);
}
[TestMethod]
public void AllKnownFieldIdsCanBeFoundInTheContainsMethod()
{
var type = typeof(BuiltInFieldId);
var allIdFields = type
.GetFields(BindingFlags.Public|BindingFlags.Static)
.Where(x => x.FieldType == typeof(Guid))
.ToArray();
foreach (var fieldInfo in allIdFields)
{
var id = (Guid?)fieldInfo.GetValue(null) ?? Guid.Empty;
var found = BuiltInFieldId.Contains(id);
Assert.AreEqual(true, found, $"Id {fieldInfo.Name} is defined on type BuiltInFieldId but not used in Contains.");
}
}
}
}