forked from projectkudu/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepositoryFactoryFacts.cs
44 lines (40 loc) · 1.7 KB
/
RepositoryFactoryFacts.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
using System;
using Kudu.Contracts.Settings;
using Kudu.Core.SourceControl;
using Kudu.Core.Tracing;
using Moq;
using Xunit;
namespace Kudu.Core.Test
{
public class RepositoryFactoryFacts
{
[Fact]
public void EnsuringGitRepositoryThrowsIfDifferentRepositoryAlreadyExists()
{
foreach (RepositoryType repoType in Enum.GetValues(typeof(RepositoryType)))
{
foreach (RepositoryType currentType in Enum.GetValues(typeof(RepositoryType)))
{
if (repoType == currentType)
{
continue;
}
// Arrange
var repoFactory = new Mock<RepositoryFactory>(
Mock.Of<IEnvironment>(),
Mock.Of<IDeploymentSettingsManager>(),
Mock.Of<ITraceFactory>()) { CallBase = true };
repoFactory.SetupGet(f => f.IsNullRepository)
.Returns(currentType == RepositoryType.None);
repoFactory.SetupGet(f => f.IsGitRepository)
.Returns(currentType == RepositoryType.Git);
repoFactory.SetupGet(f => f.IsHgRepository)
.Returns(currentType == RepositoryType.Mercurial);
// Act and Assert
var ex = Assert.Throws<InvalidOperationException>(() => repoFactory.Object.EnsureRepository(repoType));
Assert.Equal(String.Format("Expected a '{0}' repository but found a '{1}' repository at path ''.", repoType, currentType), ex.Message);
}
}
}
}
}