~ubuntu-branches/ubuntu/vivid/monodevelop/vivid-proposed

« back to all changes in this revision

Viewing changes to src/addins/Xml/Tests/Schema/SchemaTestFixtureBase.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2014-10-09 14:09:23 UTC
  • mfrom: (10.3.5)
  • Revision ID: package-import@ubuntu.com-20141009140923-s0d22u5f9kg8jvds
Tags: 5.5.0.227-1
* [b2c8331] Imported Upstream version 5.5.0.227 (Closes: #754316)
* [d210995] Delete obsolete patches
* [1b59ae1] Clear patch fizz, via quilt refresh
* [3dd147d] Fix error in configure.in which applies for tarball builds but 
  not git builds when running autoreconf
* [21c2a57] Remove Metacity references for good
* [3331661] Ensure NUnit 2.6.3 is installed
* [fd85c88] Build-depend on NuGet
* [a1ae116] Add WebKit to build dependencies, for Xwt moduleref resolution
* [9b4cf12] Since the GDB addin is integrated now, declare it in 
  debian/control
* [6231562] Correct NUnit links
* [3d2b693] Fix NuGet addin, by copying libs locally
* [74bf9a8] Don't symlink unused Mocks NUnit assembly
* [ade52b2] Ensure IKVM.Reflection is built with default (4.5) profile

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using ICSharpCode.NRefactory.Completion;
 
2
using MonoDevelop.Ide.CodeCompletion;
 
3
using MonoDevelop.Xml.Completion;
 
4
using NUnit.Framework;
 
5
using System;
 
6
using System.IO;
 
7
 
 
8
namespace MonoDevelop.Xml.Tests.Schema
 
9
{
 
10
        [TestFixture]
 
11
        public abstract class SchemaTestFixtureBase
 
12
        {
 
13
                XmlSchemaCompletionData schemaCompletionData;
 
14
 
 
15
                /// <summary>
 
16
                /// Gets the <see cref="XmlSchemaCompletionData"/> object generated
 
17
                /// by this class.
 
18
                /// </summary>
 
19
                /// <remarks>This object will be null until the <see cref="FixtureInitBase"/>
 
20
                /// has been run.</remarks>
 
21
                public XmlSchemaCompletionData SchemaCompletionData {
 
22
                        get {
 
23
                                return schemaCompletionData;
 
24
                        }
 
25
                }
 
26
                
 
27
                /// <summary>
 
28
                /// Creates the <see cref="XmlSchemaCompletionData"/> object from 
 
29
                /// the derived class's schema.
 
30
                /// </summary>
 
31
                /// <remarks>Calls <see cref="FixtureInit"/> at the end of the method.
 
32
                /// </remarks>
 
33
                [TestFixtureSetUp]
 
34
                public void FixtureInitBase()
 
35
                {
 
36
                        schemaCompletionData = CreateSchemaCompletionDataObject();
 
37
                        FixtureInit();
 
38
                }
 
39
                
 
40
                /// <summary>
 
41
                /// Method overridden by derived class so it can execute its own
 
42
                /// fixture initialisation.
 
43
                /// </summary>
 
44
                public virtual void FixtureInit()
 
45
                {
 
46
                }
 
47
        
 
48
                /// <summary>
 
49
                /// Checks whether the specified name exists in the completion data.
 
50
                /// </summary>
 
51
                public static bool Contains(CompletionDataList items, string name)
 
52
                {
 
53
                        bool Contains = false;
 
54
                        
 
55
                        foreach (ICompletionData data in items) {
 
56
                                if (data.DisplayText == name) {
 
57
                                        Contains = true;
 
58
                                        break;
 
59
                                }
 
60
                        }
 
61
                                
 
62
                        return Contains;
 
63
                }
 
64
                
 
65
                /// <summary>
 
66
                /// Checks whether the completion data specified by name has
 
67
                /// the correct description.
 
68
                /// </summary>
 
69
                public static bool ContainsDescription(CompletionDataList items, string name, string description)
 
70
                {
 
71
                        bool Contains = false;
 
72
                        
 
73
                        foreach (ICompletionData data in items) {
 
74
                                if (data.DisplayText == name) {
 
75
                                        if (data.Description == description) {
 
76
                                                Contains = true;
 
77
                                                break;                                          
 
78
                                        }
 
79
                                }
 
80
                        }
 
81
                                
 
82
                        return Contains;
 
83
                }               
 
84
                
 
85
                /// <summary>
 
86
                /// Gets a count of the number of occurrences of a particular name
 
87
                /// in the completion data.
 
88
                /// </summary>
 
89
                public static int GetItemCount(CompletionDataList items, string name)
 
90
                {
 
91
                        int count = 0;
 
92
                        
 
93
                        foreach (ICompletionData data in items) {
 
94
                                if (data.DisplayText == name) {
 
95
                                        ++count;
 
96
                                }
 
97
                        }
 
98
                        
 
99
                        return count;
 
100
                }
 
101
                
 
102
                /// <summary>
 
103
                /// Returns the schema that will be used in this test fixture.
 
104
                /// </summary>
 
105
                /// <returns></returns>
 
106
                protected virtual string GetSchema()
 
107
                {
 
108
                        return String.Empty;
 
109
                }
 
110
                
 
111
                /// <summary>
 
112
                /// Creates an <see cref="XmlSchemaCompletionData"/> object that 
 
113
                /// will be used in the test fixture.
 
114
                /// </summary>
 
115
                protected virtual XmlSchemaCompletionData CreateSchemaCompletionDataObject()
 
116
                {
 
117
                        StringReader reader = new StringReader(GetSchema());
 
118
                        return new XmlSchemaCompletionData(reader);
 
119
                }
 
120
        }
 
121
}