Skip to content

Commit c071c35

Browse files
committed
Add some more unit tests
1 parent a384d69 commit c071c35

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Mvc/Mvc.Core/test/ProducesAttributeTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,29 @@ public void ProducesAttribute_WithTypeOnly_DoesNotSetContentTypes()
151151
Assert.Empty(producesAttribute.ContentTypes);
152152
}
153153

154+
[Fact]
155+
public void ProducesAttribute_SetsDescription()
156+
{
157+
// Arrange
158+
var producesAttribute = new ProducesAttribute(typeof(Person))
159+
{
160+
Description = "Example"
161+
};
162+
163+
// Act and Assert
164+
Assert.Equal("Example", producesAttribute.Description);
165+
}
166+
167+
[Fact]
168+
public void ProducesAttribute_WithTypeOnly_DoesNotSetDescription()
169+
{
170+
// Arrange
171+
var producesAttribute = new ProducesAttribute(typeof(Person));
172+
173+
// Act and Assert
174+
Assert.Null(producesAttribute.Description);
175+
}
176+
154177
private static ResultExecutedContext CreateResultExecutedContext(ResultExecutingContext context)
155178
{
156179
return new ResultExecutedContext(context, context.Filters, context.Result, context.Controller);

src/Mvc/Mvc.Core/test/ProducesResponseTypeAttributeTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,29 @@ public void ProducesResponseTypeAttribute_WithTypeOnly_DoesNotSetContentTypes()
6767
Assert.Null(producesResponseTypeAttribute.ContentTypes);
6868
}
6969

70+
[Fact]
71+
public void ProducesResponseTypeAttribute_SetsDescription()
72+
{
73+
// Arrange
74+
var producesResponseTypeAttribute = new ProducesResponseTypeAttribute(typeof(Person), StatusCodes.Status200OK)
75+
{
76+
Description = "Example"
77+
};
78+
79+
// Act and Assert
80+
Assert.Equal("Example", producesResponseTypeAttribute.Description);
81+
}
82+
83+
[Fact]
84+
public void ProducesResponseTypeAttribute_WithTypeOnly_DoesNotSetDescription()
85+
{
86+
// Arrange
87+
var producesResponseTypeAttribute = new ProducesResponseTypeAttribute(typeof(Person), StatusCodes.Status200OK);
88+
89+
// Act and Assert
90+
Assert.Null(producesResponseTypeAttribute.Description);
91+
}
92+
7093
private class Person
7194
{
7295
public int Id { get; set; }

0 commit comments

Comments
 (0)