/
CreateContributorHandlerHandle.cs
35 lines (29 loc) · 1.03 KB
/
CreateContributorHandlerHandle.cs
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
using Ardalis.SharedKernel;
using Clean.Architecture.Core.ContributorAggregate;
using Clean.Architecture.UseCases.Contributors.Create;
using FluentAssertions;
using NSubstitute;
using Xunit;
namespace Clean.Architecture.UnitTests.UseCases.Contributors;
public class CreateContributorHandlerHandle
{
private readonly string _testName = "test name";
private readonly IRepository<Contributor> _repository = Substitute.For<IRepository<Contributor>>();
private CreateContributorHandler _handler;
public CreateContributorHandlerHandle()
{
_handler = new CreateContributorHandler(_repository);
}
private Contributor CreateContributor()
{
return new Contributor(_testName);
}
[Fact]
public async Task ReturnsSuccessGivenValidName()
{
_repository.AddAsync(Arg.Any<Contributor>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(CreateContributor()));
var result = await _handler.Handle(new CreateContributorCommand(_testName, null), CancellationToken.None);
result.IsSuccess.Should().BeTrue();
}
}