Datei: UnitTestGenerator/TestGenerator/Code/TestFixture.cs

Last Commit (0bec001)
1 //
2 // Copyright (c) 2002-2016 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22
23 using System;
24 using CodeGenerator;
25
26 namespace TestGenerator
27 {
28 ····/// <summary>
29 ····/// Summary for PersistentClass.
30 ····/// </summary>
31 ····public class TestFixture : Class
32 ····{
33 ········Function setUp;
34 ········public Function SetUp
35 ········{
36 ············get { return setUp; }
37 ········}
38 ········Function tearDown;
39 ········public Function TearDown
40 ········{
41 ············get { return tearDown; }
42 ········}
43
44 ········public TestFixture(string nameSpace, string name) : base (false, nameSpace, name, null)
45 ········{············
46 ············setUp = new Function("void", "Setup");
47 ············setUp.Attributes.Add("SetUp");
48 ············setUp.AccessModifier = "public";
49 ············this.Functions.Add(setUp);
50
51 ············tearDown = new Function("void", "TearDown");
52 ············tearDown.Attributes.Add("TearDown");
53 ············tearDown.AccessModifier = "public";
54 ············this.Functions.Add(tearDown);
55 ········}
56
57 ········protected override string GenerateHeader(bool isAbstract, string name, Class baseClass)
58 ········{
59 return "[TestFixture]\n" + base. GenerateHeader ( isAbstract, name, baseClass) ;
 
60 ········}
61
62 ····}
63 }
64
New Commit (6d63e12)
1 //
2 // Copyright (c) 2002-2016 Mirko Matytschak
3 // (www.netdataobjects.de)
4 //
5 // Author: Mirko Matytschak
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8 // documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
10 // Software, and to permit persons to whom the Software is furnished to do so, subject to the following
11 // conditions:
12
13 // The above copyright notice and this permission notice shall be included in all copies or substantial portions
14 // of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 // TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
19 // CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
21
22
23 using System;
24 using CodeGenerator;
25
26 namespace TestGenerator
27 {
28 ····/// <summary>
29 ····/// Summary for PersistentClass.
30 ····/// </summary>
31 ····public class TestFixture : Class
32 ····{
33 ········Function setUp;
34 ········public Function SetUp
35 ········{
36 ············get { return setUp; }
37 ········}
38 ········Function tearDown;
39 ········public Function TearDown
40 ········{
41 ············get { return tearDown; }
42 ········}
43
44 ········public TestFixture(string nameSpace, string name) : base (false, nameSpace, name, null)
45 ········{············
46 ············setUp = new Function("void", "Setup");
47 ············setUp.Attributes.Add("SetUp");
48 ············setUp.AccessModifier = "public";
49 ············this.Functions.Add(setUp);
50
51 ············tearDown = new Function("void", "TearDown");
52 ············tearDown.Attributes.Add("TearDown");
53 ············tearDown.AccessModifier = "public";
54 ············this.Functions.Add(tearDown);
55 ········}
56
57 ········protected override string GenerateHeader(bool isAbstract, string name, Class baseClass)
58 ········{
59 var cls = new Class( this. nameSpace, "NDOTest") ;
60 ············return "[TestFixture]\n" + base.GenerateHeader (isAbstract, name, cls);
61 ········}
62
63 ····}
64 }
65