-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathContributionsControllerTests.Logic.GetById.cs
More file actions
50 lines (41 loc) · 1.83 KB
/
ContributionsControllerTests.Logic.GetById.cs
File metadata and controls
50 lines (41 loc) · 1.83 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
// ----------------------------------------------------------------------------------
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers
// ----------------------------------------------------------------------------------
using System;
using System.Threading.Tasks;
using Force.DeepCloner;
using GitFyle.Core.Api.Models.Foundations.Contributions;
using Microsoft.AspNetCore.Mvc;
using Moq;
using RESTFulSense.Clients.Extensions;
namespace GitFyle.Core.Api.Tests.Unit.Controllers.Contributions
{
public partial class ContributionsControllerTests
{
[Fact]
public async Task ShouldReturnOkWithRecordOnGetByIdAsync()
{
// given
Contribution randomContribution = CreateRandomContribution();
Guid inputId = randomContribution.Id;
Contribution storageContribution = randomContribution;
Contribution expectedContribution = storageContribution.DeepClone();
var expectedObjectResult =
new OkObjectResult(expectedContribution);
var expectedActionResult =
new ActionResult<Contribution>(expectedObjectResult);
contributionServiceMock
.Setup(service => service.RetrieveContributionByIdAsync(It.IsAny<Guid>()))
.ReturnsAsync(storageContribution);
// when
ActionResult<Contribution> actualActionResult =
await contributionsController.GetContributionByIdAsync(inputId);
// then
actualActionResult.ShouldBeEquivalentTo(expectedActionResult);
contributionServiceMock
.Verify(service => service.RetrieveContributionByIdAsync(It.IsAny<Guid>()),
Times.Once);
contributionServiceMock.VerifyNoOtherCalls();
}
}
}