/
TargetWithoutSources.cs
76 lines (61 loc) · 1.97 KB
/
TargetWithoutSources.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
namespace bs.Tests
{
[TestFixture]
class TargetWithoutSources : DependencyGraphTests
{
[SetUp]
public new void Setup()
{
SetupGraphWithOneTargetWithoutSources();
}
[Test]
public void WillGenerateTargetWithoutSources()
{
_depGraph.RequestTarget(defaulttargetFile);
FileAssert.Contains(defaulttargetFile, "Hello");
}
[Test]
public void WontGenerateTargetWithoutSourcesTwice()
{
_depGraph.RequestTarget(defaulttargetFile);
FileAssert.Contains(defaulttargetFile, "Hello");
ThrowIfDepgraphGenerates();
_depGraph.RequestTarget(defaulttargetFile);
}
[Test]
public void WillGenerateTargetIfItWasNeverBuiltBefore()
{
File.WriteAllText(defaulttargetFile, "One");
_depGraph.RequestTarget(defaulttargetFile);
FileAssert.Contains(defaulttargetFile, "Hello");
}
[Test]
public void RegenerateWhenActionHashChanges()
{
_depGraph.RequestTarget(defaulttargetFile);
_depGraph = new DependencyGraph(_buildHistory);
bool invoked = false;
var action = new SimpleAction((t, s) => { invoked=true; }, "hash2");
_depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions()
{
Action = action,
Settings = new TargetGenerateSettings(new HashSet<string>(), action.GetActionHash())
});
_depGraph.RequestTarget(defaulttargetFile);
Assert.IsTrue(invoked);
}
private void SetupGraphWithOneTargetWithoutSources()
{
var simpleAction = new SimpleAction((t,s) => File.WriteAllText(t, "Hello"), "hash1");
_depGraph.RegisterTarget(defaulttargetFile, new TargetGenerateInstructions()
{
Action = simpleAction,
Settings = new TargetGenerateSettings(new HashSet<string>(),simpleAction.GetActionHash())
});
}
}
}