blob: 58cacd7554e2d2077f35fe5f81c84b6809fe98d0 (
plain)
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
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Linq;
using System.Web.Http.Controllers;
using Moq;
using Xunit;
using Assert = Microsoft.TestCommon.AssertEx;
namespace System.Web.Http
{
public class HttpParameterDescriptorTest
{
[Fact]
public void Default_Constructor()
{
HttpParameterDescriptor parameterDescriptor = new Mock<HttpParameterDescriptor>().Object;
Assert.Null(parameterDescriptor.ParameterName);
Assert.Null(parameterDescriptor.ParameterType);
Assert.Null(parameterDescriptor.Configuration);
Assert.Null(parameterDescriptor.Prefix);
Assert.Null(parameterDescriptor.ModelBinderAttribute);
Assert.Null(parameterDescriptor.ActionDescriptor);
Assert.Null(parameterDescriptor.DefaultValue);
Assert.NotNull(parameterDescriptor.Properties);
}
[Fact]
public void Configuration_Property()
{
HttpConfiguration config = new HttpConfiguration();
HttpParameterDescriptor parameterDescriptor = new Mock<HttpParameterDescriptor> { CallBase = true }.Object;
Assert.Reflection.Property<HttpParameterDescriptor, HttpConfiguration>(
instance: parameterDescriptor,
propertyGetter: pd => pd.Configuration,
expectedDefaultValue: null,
allowNull: false,
roundTripTestValue: config);
}
[Fact]
public void ActionDescriptor_Property()
{
HttpParameterDescriptor parameterDescriptor = new Mock<HttpParameterDescriptor> { CallBase = true }.Object;
HttpActionDescriptor actionDescriptor = new Mock<HttpActionDescriptor>().Object;
Assert.Reflection.Property<HttpParameterDescriptor, HttpActionDescriptor>(
instance: parameterDescriptor,
propertyGetter: pd => pd.ActionDescriptor,
expectedDefaultValue: null,
allowNull: false,
roundTripTestValue: actionDescriptor);
}
[Fact]
public void GetCustomAttributes_Returns_EmptyAttributes()
{
HttpParameterDescriptor parameterDescriptor = new Mock<HttpParameterDescriptor> { CallBase = true }.Object;
IEnumerable<object> attributes = parameterDescriptor.GetCustomAttributes<object>();
Assert.Equal(0, attributes.Count());
}
[Fact]
public void GetCustomAttributes_AttributeType_Returns_EmptyAttributes()
{
HttpParameterDescriptor parameterDescriptor = new Mock<HttpParameterDescriptor> { CallBase = true }.Object;
IEnumerable<FromBodyAttribute> attributes = parameterDescriptor.GetCustomAttributes<FromBodyAttribute>();
Assert.Equal(0, attributes.Count());
}
}
}
|