Skip to content

Commit 8837b44

Browse files
committed
Refactor AcceptedResultAssertions to use ObjectResultAssertionsBase.
1 parent bb704e9 commit 8837b44

File tree

2 files changed

+7
-37
lines changed

2 files changed

+7
-37
lines changed

src/FluentAssertions.AspNetCore.Mvc/AcceptedResultAssertions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public AcceptedResultAssertions(AcceptedResult subject) : base(subject)
2525

2626
#region Public Properties
2727
/// <summary>
28-
/// The location on the AcceptedResult
28+
/// The location on the AcceptedResult.
2929
/// </summary>
3030
public string Location => ObjectResultSubject.Location;
3131

src/FluentAssertions.AspNetCore.Mvc/CreatedResultAssertions.cs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
using System;
2-
using System.Diagnostics;
3-
using FluentAssertions.Execution;
4-
using FluentAssertions.Primitives;
1+
using FluentAssertions.Execution;
52
using Microsoft.AspNetCore.Mvc;
3+
using System;
4+
using System.Diagnostics;
65

76
namespace FluentAssertions.AspNetCore.Mvc
87
{
98
/// <summary>
109
/// Contains a number of methods to assert that a <see cref="CreatedResult"/> is in the expected state.
1110
/// </summary>
1211
[DebuggerNonUserCode]
13-
public class CreatedResultAssertions : ObjectAssertions
12+
public class CreatedResultAssertions : ObjectResultAssertionsBase<CreatedResult, CreatedResultAssertions>
1413
{
1514
#region Public Constructors
1615

@@ -26,42 +25,13 @@ public CreatedResultAssertions(CreatedResult subject) : base(subject)
2625

2726
#region Public Properties
2827
/// <summary>
29-
/// The value on the CreatedResult
28+
/// The location on the CreatedResult.
3029
/// </summary>
31-
public object Value => CreatedResultSubject.Value;
32-
33-
public string Location => CreatedResultSubject.Location;
34-
35-
#endregion
36-
37-
#region Private Properties
38-
private CreatedResult CreatedResultSubject => (CreatedResult)Subject;
30+
public string Location => ObjectResultSubject.Location;
3931

4032
#endregion
4133

4234
#region Public Methods
43-
/// <summary>
44-
/// Asserts the value is of the expected type.
45-
/// </summary>
46-
/// <typeparam name="TValue">The expected type.</typeparam>
47-
/// <returns>The typed value.</returns>
48-
public TValue ValueAs<TValue>()
49-
{
50-
var value = CreatedResultSubject.Value;
51-
52-
if (value == null)
53-
Execute.Assertion
54-
.WithDefaultIdentifier("CreatedResult.Value")
55-
.FailWith(FailureMessages.CommonNullWasSuppliedFailMessage, typeof(TValue));
56-
57-
Execute.Assertion
58-
.ForCondition(value is TValue)
59-
.WithDefaultIdentifier("CreatedResult.Value")
60-
.FailWith(FailureMessages.CommonTypeFailMessage, typeof(TValue), value.GetType());
61-
62-
return (TValue)value;
63-
}
64-
6535
/// <summary>
6636
/// Asserts the uri has the expected value.
6737
/// </summary>

0 commit comments

Comments
 (0)