-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathShouldExtensions.cs
More file actions
28 lines (25 loc) · 838 Bytes
/
ShouldExtensions.cs
File metadata and controls
28 lines (25 loc) · 838 Bytes
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
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Infrastructure;
namespace CommandQuery.Sample.AzureFunctions.Tests
{
public static class ShouldExtensions
{
public static void ShouldBeError(this IActionResult result, string message)
{
result.Should().NotBeNull();
result.As<IStatusCodeActionResult>().StatusCode.Should().NotBe(200);
var value = result.Value<IError>()!;
value.Should().NotBeNull();
value.Message.Should().Be(message);
}
public static T As<T>(this IActionResult result)
{
return (T)result;
}
public static T? Value<T>(this IActionResult result) where T : class
{
return result.As<ObjectResult>().Value as T;
}
}
}