-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwhen_creating_new_ship_reliably.cs
More file actions
53 lines (46 loc) · 2.04 KB
/
when_creating_new_ship_reliably.cs
File metadata and controls
53 lines (46 loc) · 2.04 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
using System.Threading.Tasks;
using AspNetCoreMvcApp.BusRequestSenders;
using CoreDddShared.Commands;
using FakeItEasy;
using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
using Shouldly;
namespace AspNetCoreMvcApp.Tests.Controllers.ManageShipsControllers
{
[TestFixture]
public class when_creating_new_ship_reliably
{
private IActionResult _actionResult;
private CreateNewShipCommand _createNewShipCommand;
private IBusRequestSender _busRequestSender;
private const int CreatedShipId = 34;
[SetUp]
public async Task Context()
{
_createNewShipCommand = new CreateNewShipCommand
{
ShipName = "ship name",
Tonnage = 23.4m,
ImoNumber = "IMO 12345"
};
var createNewShipCommandReply = new CreateNewShipCommandReply {CreatedShipId = CreatedShipId };
_busRequestSender = A.Fake<IBusRequestSender>();
A.CallTo(() => _busRequestSender.SendRequest<CreateNewShipCommandReply>(_createNewShipCommand)).Returns(createNewShipCommandReply);
var manageShipsController = new ManageShipsControllerBuilder()
.WithBusRequestSender(_busRequestSender)
.Build();
_actionResult = await manageShipsController.CreateNewShipReliably(_createNewShipCommand);
}
[Test]
public void action_result_is_redirect_to_action_result_with_last_generated_ship_id_parameterer()
{
_actionResult.ShouldBeOfType<RedirectToActionResult>();
var redirectToActionResult = (RedirectToActionResult)_actionResult;
redirectToActionResult.ControllerName.ShouldBeNull();
redirectToActionResult.ActionName.ShouldBe("CreateNewShip");
redirectToActionResult.RouteValues.ShouldNotBeNull();
redirectToActionResult.RouteValues.ContainsKey("lastCreatedShipId").ShouldBeTrue();
((int)redirectToActionResult.RouteValues["lastCreatedShipId"]).ShouldBe(CreatedShipId);
}
}
}