~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.XmlEditor/Tests/Parser/AttributeNameTestFixture.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
using MonoDevelop.XmlEditor;
 
3
using NUnit.Framework;
 
4
using System;
 
5
using System.Xml;
 
6
 
 
7
namespace MonoDevelop.XmlEditor.Tests.Parser
 
8
{
 
9
        /// <summary>
 
10
        /// Tests that we can detect the attribute's name.
 
11
        /// </summary>
 
12
        [TestFixture]
 
13
        public class AttributeNameTestFixture
 
14
        {               
 
15
                [Test]
 
16
                public void SuccessTest1()
 
17
                {
 
18
                        string text = " foo='a";
 
19
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
20
                }
 
21
 
 
22
                [Test]
 
23
                public void SuccessTest2()
 
24
                {
 
25
                        string text = " foo='";
 
26
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
27
                }               
 
28
                
 
29
                [Test]
 
30
                public void SuccessTest3()
 
31
                {
 
32
                        string text = " foo=";
 
33
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
34
                }                       
 
35
                
 
36
                [Test]
 
37
                public void SuccessTest4()
 
38
                {
 
39
                        string text = " foo=\"";
 
40
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
41
                }       
 
42
                
 
43
                [Test]
 
44
                public void SuccessTest5()
 
45
                {
 
46
                        string text = " foo = \"";
 
47
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
48
                }                       
 
49
                
 
50
                [Test]
 
51
                public void SuccessTest6()
 
52
                {
 
53
                        string text = " foo = '#";
 
54
                        Assert.AreEqual("foo", XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
55
                }       
 
56
                
 
57
                [Test]
 
58
                public void FailureTest1()
 
59
                {
 
60
                        string text = "foo=";
 
61
                        Assert.AreEqual(String.Empty, XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
62
                }               
 
63
                
 
64
                [Test]
 
65
                public void FailureTest2()
 
66
                {
 
67
                        string text = "foo=<";
 
68
                        Assert.AreEqual(String.Empty, XmlParser.GetAttributeName(text, text.Length), "Should have retrieved the attribute name 'foo'");
 
69
                }               
 
70
                
 
71
                [Test]
 
72
                public void FailureTest3()
 
73
                {
 
74
                        string text = "a";
 
75
                        Assert.AreEqual(String.Empty, XmlParser.GetAttributeName(text, text.Length));
 
76
                }       
 
77
                
 
78
                [Test]
 
79
                public void FailureTest4()
 
80
                {
 
81
                        string text = " a";
 
82
                        Assert.AreEqual(String.Empty, XmlParser.GetAttributeName(text, text.Length));
 
83
                }       
 
84
                
 
85
                [Test]
 
86
                public void EmptyString()
 
87
                {
 
88
                        Assert.AreEqual(String.Empty, XmlParser.GetAttributeName(String.Empty, 10));
 
89
                }
 
90
        }
 
91
}