-
Notifications
You must be signed in to change notification settings - Fork 0
/
IncrementalBuildTest.cs
44 lines (38 loc) · 1.92 KB
/
IncrementalBuildTest.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
namespace IncrementalBuild.Test
{
using System.Collections.Generic;
using System.IO;
using System.Linq;
using IncrementalBuild.Fx;
using Xunit;
public class IncrementalBuildTest
{
[Fact]
public void TestBasic()
{
var buildOperator = new BuildOperator();
var builder = new Builder<BuildInput, string>(buildOperator);
var inputs = new[]
{
new BuildInput{ Property1 = "miaomiao", Property2 = 2, Property3 = BuildInput.ForDependencyTestInstance.Property3, Property4 = "wangwang" },
new BuildInput{ Property1 = "eee", Property2 = 3, Property3 = BuildInput.ForDependencyTestInstance.Property3, Property4 = "houhou" },
BuildInput.ForDependencyTestInstance,
};
string cacheFolder = Path.Combine(Directory.GetCurrentDirectory(), "intermediateFolder");
Directory.CreateDirectory(cacheFolder);
var firstOutput = builder.BuildWithIncremental(inputs, new BuildContext(cacheFolder));
var secondOutput = builder.BuildWithIncremental(inputs, new BuildContext(cacheFolder));
var forceOutput = builder.BuildWithIncremental(inputs, new BuildContext(cacheFolder, true));
Assert.True(Equals(secondOutput, forceOutput));
// update BuildInput.ForDependencyTestInstance, should trigger other inputs to rebuild
BuildInput.ForDependencyTestInstance.Property3.Add("nenene");
firstOutput = builder.BuildWithIncremental(inputs, new BuildContext(cacheFolder));
forceOutput = builder.BuildWithIncremental(inputs, new BuildContext(cacheFolder, true));
Assert.True(Equals(firstOutput, forceOutput));
}
private static bool Equals<T>(IEnumerable<T> first, IEnumerable<T> second)
{
return !(first.Except(second).Any() || second.Except(first).Any());
}
}
}