forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpRouteValueDictionaryTest.cs
More file actions
82 lines (73 loc) · 2.88 KB
/
Copy pathHttpRouteValueDictionaryTest.cs
File metadata and controls
82 lines (73 loc) · 2.88 KB
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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.TestCommon;
namespace System.Web.Http.Routing
{
public class HttpRouteValueDictionaryTest
{
private static readonly Dictionary<string, object> data0 = null;
private static readonly Dictionary<string, object> data1 = new Dictionary<string, object>();
private static readonly Dictionary<string, object> data2 = new Dictionary<string, object>
{
{ "key1", "value1" },
{ "key2", 2 },
{ "key3", TimeSpan.FromDays(1) },
};
public static TheoryDataSet<Dictionary<string, object>, Dictionary<string, object>> DictionaryConstructorData
{
get
{
// Input, expected output
return new TheoryDataSet<Dictionary<string, object>, Dictionary<string, object>>
{
{ null, data1 },
{ data0, data1 },
{ data1, data1 },
{ data2, data2 },
};
}
}
public static TheoryDataSet<object, Dictionary<string, object>> ObjectConstructorData
{
get
{
// Input, expected output
return new TheoryDataSet<object, Dictionary<string, object>>
{
{ null, data1 },
{ data0, data1 },
{ data1, data1 },
{ new { }, data1},
{ data2, data2 },
{ new { key1 = "value1", key2 = 2, key3 = TimeSpan.FromDays(1) }, data2},
};
}
}
[Theory]
[PropertyData("DictionaryConstructorData")]
public void Constructor_AcceptsDictionaryValues(Dictionary<string, object> input, Dictionary<string, object> expectedOutput)
{
HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary(input);
Assert.True(expectedOutput.SequenceEqual(routeValues));
}
[Theory]
[PropertyData("ObjectConstructorData")]
public void Constructor_AcceptsObjectValues(object input, Dictionary<string, object> expectedOutput)
{
HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary(input);
Assert.True(expectedOutput.SequenceEqual(routeValues));
}
[Fact]
public void Constructor_IsCaseInsensitive()
{
// Arrange
HttpRouteValueDictionary routeValues = new HttpRouteValueDictionary();
// Act
routeValues.Add("KEY", null);
// Assert
Assert.True(routeValues.ContainsKey("key"));
}
}
}