-
Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathSolutionStructure.cs
43 lines (37 loc) · 1.74 KB
/
SolutionStructure.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
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
namespace IntegrityTests
{
public class SolutionStructure
{
[Test]
public void OneSolutionPerDirectory()
{
var directoriesWithMoreThanOneSolution = Directory.GetFiles(TestSetup.DocsRootPath, "*.sln", SearchOption.AllDirectories)
.Select(Path.GetDirectoryName)
.Where(dirPath => !dirPath.Contains(Path.Combine("samples", "versioning"))) //Exception for the Versioning sample
.GroupBy(dirPath => dirPath, StringComparer.OrdinalIgnoreCase)
.Where(group => group.Count() > 1)
.Select(group => group.Key)
.ToArray();
var errMsg = $"Only one solution file allowed per directory. These have multiple:" + Environment.NewLine
+ string.Join(Environment.NewLine, directoriesWithMoreThanOneSolution);
Assert.That(directoriesWithMoreThanOneSolution, Is.Empty, errMsg);
}
[Test]
public void OneProjectPerDirectory()
{
var directoriesWithMoreThanOneProject = Directory.GetFiles(TestSetup.DocsRootPath, "*.*proj", SearchOption.AllDirectories)
.Select(Path.GetDirectoryName)
.GroupBy(dirPath => dirPath, StringComparer.OrdinalIgnoreCase)
.Where(group => group.Count() > 1)
.Select(group => group.Key)
.ToArray();
var errMsg = $"Only one project file allowed per directory. These have multiple:" + Environment.NewLine
+ string.Join(Environment.NewLine, directoriesWithMoreThanOneProject);
Assert.That(directoriesWithMoreThanOneProject, Is.Empty, errMsg);
}
}
}