-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathCloseCommandTests.cs
52 lines (45 loc) · 1.7 KB
/
CloseCommandTests.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// -----------------------------------------------------------------------
// <copyright file="CloseCommandTests.cs" company="GitTools Contributors">
// Copyright (c) 2015 - Present - GitTools Contributors
// </copyright>
// -----------------------------------------------------------------------
using System.Threading.Tasks;
using GitReleaseManager.Core.Commands;
using GitReleaseManager.Core.Options;
using NSubstitute;
using NUnit.Framework;
using Serilog;
using Shouldly;
namespace GitReleaseManager.Core.Tests.Commands
{
[TestFixture]
public class CloseCommandTests
{
private IVcsService _vcsService;
private ILogger _logger;
private CloseCommand _command;
[SetUp]
public void Setup()
{
_vcsService = Substitute.For<IVcsService>();
_logger = Substitute.For<ILogger>();
_command = new CloseCommand(_vcsService, _logger);
}
[Test]
public async Task Should_Execute_Command()
{
var options = new CloseSubOptions
{
RepositoryOwner = "owner",
RepositoryName = "repository",
Milestone = "0.1.0",
};
_vcsService.CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone)
.Returns(Task.CompletedTask);
var result = await _command.Execute(options).ConfigureAwait(false);
result.ShouldBe(0);
await _vcsService.Received(1).CloseMilestoneAsync(options.RepositoryOwner, options.RepositoryName, options.Milestone).ConfigureAwait(false);
_logger.Received(1).Information(Arg.Any<string>(), options.Milestone);
}
}
}