1 // ================================================================================================
3 // MediaWikiVariableのテストクラスソース。</summary>
5 // <copyright file="MediaWikiVariableTest.cs" company="honeplusのメモ帳">
6 // Copyright (C) 2012 Honeplus. All rights reserved.</copyright>
9 // ================================================================================================
11 namespace Honememo.Wptscs.Parsers
14 using Honememo.Parsers;
15 using Microsoft.VisualStudio.TestTools.UnitTesting;
18 /// <see cref="MediaWikiVariable"/>のテストクラスです。
21 public class MediaWikiVariableTest
29 public void TestConstructor()
31 MediaWikiVariable element;
34 element = new MediaWikiVariable(null);
35 Assert.IsNull(element.Variable);
36 Assert.IsNull(element.Value);
38 element = new MediaWikiVariable("変数名1");
39 Assert.AreEqual("変数名1", element.Variable);
40 Assert.IsNull(element.Value);
42 value = new TextElement("値");
43 element = new MediaWikiVariable("変数名2", value);
44 Assert.AreEqual("変数名2", element.Variable);
45 Assert.AreSame(value, element.Value);
53 /// Variableプロパティテストケース。
56 public void TestVariable()
58 MediaWikiVariable element = new MediaWikiVariable("変数名");
60 Assert.AreEqual("変数名", element.Variable);
61 element.Variable = "test";
62 Assert.AreEqual("test", element.Variable);
63 element.Variable = null;
64 Assert.IsNull(element.Variable);
71 public void TestValue()
73 MediaWikiVariable element = new MediaWikiVariable("変数名");
74 IElement value = new TextElement("値");
76 Assert.IsNull(element.Value);
77 element.Value = value;
78 Assert.AreSame(value, element.Value);
80 Assert.IsNull(element.Value);
85 #region インタフェース実装メソッドテストケース
88 /// ToStringメソッドテストケース。
91 public void TestToString()
93 MediaWikiVariable element = new MediaWikiVariable("変数名");
96 Assert.AreEqual("{{{変数名}}}", element.ToString());
99 element.Value = new TextElement("値");
100 Assert.AreEqual("{{{変数名|値}}}", element.ToString());
103 ListElement list = new ListElement();
104 list.Add(new MediaWikiLink("記事名"));
105 list.Add(new MediaWikiTemplate("テンプレート名"));
106 element.Value = list;
107 Assert.AreEqual("{{{変数名|[[記事名]]{{テンプレート名}}}}}", element.ToString());