|
6 | 6 | using GitVersion.Model.Configuration;
|
7 | 7 | using GitVersion.VersionCalculation;
|
8 | 8 | using GitVersionCore.Tests.Helpers;
|
9 |
| -using GitVersionCore.Tests.Mocks; |
10 | 9 | using LibGit2Sharp;
|
11 | 10 | using Microsoft.Extensions.DependencyInjection;
|
12 | 11 | using Microsoft.Extensions.Options;
|
@@ -36,11 +35,10 @@ public void CanInheritVersioningMode(VersioningMode mode)
|
36 | 35 | var branches = Substitute.For<IBranchCollection>();
|
37 | 36 | branches.GetEnumerator().Returns(_ => ((IEnumerable<IBranch>)new[] { mockBranch }).GetEnumerator());
|
38 | 37 |
|
39 |
| - var mockRepository = new MockRepository |
40 |
| - { |
41 |
| - Head = mockBranch, |
42 |
| - Branches = branches |
43 |
| - }; |
| 38 | + var mockRepository = Substitute.For<IGitRepository>(); |
| 39 | + mockRepository.Head.Returns(mockBranch); |
| 40 | + mockRepository.Branches.Returns(branches); |
| 41 | + mockRepository.Commits.Returns(mockBranch.Commits); |
44 | 42 |
|
45 | 43 | var context = GetGitVersionContext(fixture.RepositoryPath, mockRepository, branchName, config);
|
46 | 44 |
|
@@ -100,11 +98,10 @@ public void UsesBranchSpecificConfigOverTopLevelDefaults()
|
100 | 98 | var branches = Substitute.For<IBranchCollection>();
|
101 | 99 | branches.GetEnumerator().Returns(_ => ((IEnumerable<IBranch>)new[] { master, develop }).GetEnumerator());
|
102 | 100 |
|
103 |
| - var mockRepository = new MockRepository |
104 |
| - { |
105 |
| - Head = develop, |
106 |
| - Branches = branches |
107 |
| - }; |
| 101 | + var mockRepository = Substitute.For<IGitRepository>(); |
| 102 | + mockRepository.Head.Returns(develop); |
| 103 | + mockRepository.Branches.Returns(branches); |
| 104 | + mockRepository.Commits.Returns(develop.Commits); |
108 | 105 |
|
109 | 106 | var context = GetGitVersionContext(fixture.RepositoryPath, mockRepository, branchName, config);
|
110 | 107 |
|
@@ -144,16 +141,15 @@ public void UsesFirstBranchConfigWhenMultipleMatch()
|
144 | 141 | var branches = Substitute.For<IBranchCollection>();
|
145 | 142 | branches.GetEnumerator().Returns(_ => ((IEnumerable<IBranch>)new[] { releaseLatestBranch, releaseVersionBranch }).GetEnumerator());
|
146 | 143 |
|
147 |
| - var mockRepository = new MockRepository |
148 |
| - { |
149 |
| - Branches = branches, |
150 |
| - Head = releaseLatestBranch |
151 |
| - }; |
| 144 | + var mockRepository = Substitute.For<IGitRepository>(); |
| 145 | + mockRepository.Branches.Returns(branches); |
| 146 | + mockRepository.Head.Returns(releaseLatestBranch); |
| 147 | + mockRepository.Commits.Returns(releaseLatestBranch.Commits); |
152 | 148 |
|
153 | 149 | var latestContext = GetGitVersionContext(fixture.RepositoryPath, mockRepository, releaseLatestBranch.CanonicalName, config);
|
154 | 150 | latestContext.Configuration.Increment.ShouldBe(IncrementStrategy.None);
|
155 | 151 |
|
156 |
| - mockRepository.Head = releaseVersionBranch; |
| 152 | + mockRepository.Head.Returns(releaseVersionBranch); |
157 | 153 | var versionContext = GetGitVersionContext(fixture.RepositoryPath, mockRepository, releaseVersionBranch.CanonicalName, config);
|
158 | 154 | versionContext.Configuration.Increment.ShouldBe(IncrementStrategy.Patch);
|
159 | 155 | }
|
|
0 commit comments