-
Notifications
You must be signed in to change notification settings - Fork 1k
/
MockTaskItem.cs
82 lines (69 loc) · 2.06 KB
/
MockTaskItem.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections;
using Microsoft.Build.Framework;
namespace Microsoft.NET.Build.Tasks.UnitTests
{
public class MockTaskItem : ITaskItem
{
private Dictionary<string, string> _metadata = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
public MockTaskItem()
{
}
public MockTaskItem(string itemSpec, Dictionary<string, string> metadata)
{
ItemSpec = itemSpec;
foreach(var m in metadata)
{
_metadata.Add(m.Key, m.Value);
}
}
public string ItemSpec { get; set; }
public int MetadataCount
{
get
{
return _metadata.Count;
}
}
public ICollection MetadataNames
{
get
{
return _metadata.Keys;
}
}
public IDictionary CloneCustomMetadata()
{
throw new NotImplementedException();
}
public void CopyMetadataTo(ITaskItem destinationItem)
{
foreach (var kv in _metadata)
{
destinationItem.SetMetadata(kv.Key, kv.Value);
}
}
public string GetMetadata(string metadataName)
{
string metadataValue = null;
if (_metadata.TryGetValue(metadataName, out metadataValue))
{
return metadataValue ?? string.Empty;
}
return string.Empty;
}
public void RemoveMetadata(string metadataName)
{
string metadataValue = null;
if (_metadata.TryGetValue(metadataName, out metadataValue))
{
_metadata.Remove(metadataName);
}
}
public void SetMetadata(string metadataName, string metadataValue)
{
_metadata[metadataName] = metadataValue;
}
}
}