My favorites | Sign in
Logo
                
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
using System ;
using System.Collections.Generic ;
using System.Linq ;
using Xunit ;

namespace Dunn.TreeTrim.Specs
{
public class TaskCollectionSpecs
{
public class When_used_correctly : ContextSpecification
{
TaskCollection _tasks;

public override void EstablishContext()
{
_tasks = new TaskCollection(
new StubPluginDiscoverer( @"gzip", @"email" ).DiscoveredPlugins,
new List<string>
{
@"-gzip:",
@"-email:something:with:colons"
} );
}

public override void Because()
{

}

[Fact]
public void it_should_have_the_correct_amount_of_tasks()
{
Assert.Equal( 2, _tasks.Count( ) );
}

[Fact]
public void it_should_store_all_arguments()
{
ITask gzipItem = _tasks.ElementAt( 0 );
Assert.Equal( @"gzip", gzipItem.Moniker );
Assert.Equal( string.Empty, gzipItem.SettingsValue );

ITask emailItem = _tasks.ElementAt( 1 );
Assert.Equal( @"email", emailItem.Moniker );
Assert.Equal( @"something:with:colons", emailItem.SettingsValue );
}

[Fact]
public void it_should_iterate_over_the_tasks()
{
IEnumerator<ITask> enumerator = _tasks.GetEnumerator( );
Assert.True( enumerator.MoveNext( ) );
Assert.True( enumerator.MoveNext( ) );

Assert.False( enumerator.MoveNext( ) );
}

[Fact]
public void it_should_handle_values_with_colons()
{
ITask task = _tasks.ElementAt( 1 );

Assert.Equal( @"something:with:colons", task.SettingsValue );
}

}

public class When_a_task_has_complex_arguments : ContextSpecification
{
TaskCollection _tasks;

public override void EstablishContext()
{
_tasks = new TaskCollection(
new StubPluginDiscoverer( @"email" ).DiscoveredPlugins,
new List<string>
{
@"-email:from:steve@dunnhq.com+to:joe@bloggs.com+subject:""Emailing {{FileName}}""+body:""This is the body""+otherAttachments:""c:\temp\disclaimer.txt;c:\temp\copyright.txt"""
}
);
}

public override void Because()
{

}

[Fact]
public void it_should_store_the_moniker()
{
ITask task = _tasks.First( );
Assert.Equal( @"email", task.Moniker );
}

[Fact]
public void it_should_store_the_whole_settings_value()
{
ITask task = _tasks.First( );

Assert.Equal(
@"from:steve@dunnhq.com+to:joe@bloggs.com+subject:""Emailing {{FileName}}""+body:""This is the body""+otherAttachments:""c:\temp\disclaimer.txt;c:\temp\copyright.txt""",
task.SettingsValue );
}

[Fact]
public void it_should_store_the_parameters()
{
ITask task = _tasks.First( );

Assert.Equal( @"steve@dunnhq.com", task[ @"from" ] );
Assert.Equal( @"joe@bloggs.com", task[ @"to" ] );
Assert.Equal( @"""Emailing {{FileName}}""", task[ @"subject" ] );
Assert.Equal( @"""This is the body""", task[ @"body" ] );
Assert.Equal( @"""c:\temp\disclaimer.txt;c:\temp\copyright.txt""", task[ @"otherAttachments" ] );
}
}
}
}
Show details Hide details

Change log

r27 by steve.j.dunn on Apr 13, 2009   Diff
[No log message]
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 4022 bytes, 118 lines
Hosted by Google Code