-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathRequestHelperTests.cs
59 lines (51 loc) · 1.92 KB
/
RequestHelperTests.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
54
55
56
57
58
59
using System.Collections.Generic;
using aggregator;
using Microsoft.Extensions.Logging;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.WebApi;
using Xunit;
namespace unittests_function
{
public class RequestHelperTests
{
[Fact]
public void MigrateIdentityInformationUpdatesIdentityFields()
{
var logger = NSubstitute.Substitute.For<ILogger>();
WorkItem workItem = new WorkItem
{
Fields = new Dictionary<string, object>
{
{ "System.WorkItemType", "Bug" },
{ "FixedBy", "Jane Doe <jdoe@example.com>" },
},
};
new RequestHelper(logger).MigrateIdentityInformation("1.0", workItem);
var identityValue = workItem.Fields["FixedBy"];
Assert.IsType<IdentityRef>(identityValue);
Assert.Equal("Jane Doe", ((IdentityRef)identityValue).DisplayName);
Assert.Equal("jdoe@example.com", ((IdentityRef)identityValue).UniqueName);
}
[Fact]
public void MigrateIdentityInformationDoesNotUpdateStrings()
{
var logger = NSubstitute.Substitute.For<ILogger>();
WorkItem workItem = new WorkItem
{
Fields = new Dictionary<string, object>
{
{ "System.WorkItemType", "Bug" },
{ "VerifyBy", "GA" },
{ "SmileTo", ">_<" },
},
};
new RequestHelper(logger).MigrateIdentityInformation("1.0", workItem);
var stringValue = workItem.Fields["VerifyBy"];
Assert.IsType<string>(stringValue);
Assert.Equal("GA", stringValue);
stringValue = workItem.Fields["SmileTo"];
Assert.IsType<string>(stringValue);
Assert.Equal(">_<", stringValue);
}
}
}