summaryrefslogtreecommitdiff
path: root/bindings/csharp/tests/ModuleTests.cs
blob: 71cbea876347b475f540b458a2def0d9dc2c9c22 (plain)
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Copyright 2014  CrossWire Bible Society (http://www.crosswire.org)
//  	CrossWire Bible Society
//  	P. O. Box 2528
//  	Tempe, AZ  85280-2528
//  
//  This program is free software; you can redistribute it and/or modify it
//  under the terms of the GNU General Public License as published by the
//  Free Software Foundation version 2.
//  
//  This program is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  General Public License for more details.
using System;
using NUnit.Framework;
using System.IO;

namespace Sword.Tests
{
	[TestFixture]
	public class ModuleTests
	{
		Module _swordModule;
		Manager _swordManager;
		
		[TestFixtureSetUp]
		public void Setup()
		{
			_swordManager = new Manager("LocalManager");
			_swordModule = _swordManager.GetModuleByName("ESV");
			
			if(_swordModule != null)
			{
				return;	
			}
			using(var installManager = new InstallManager("baseDirectory"))
			{
				installManager.SetUserDisclaimerConfirmed();
				installManager.SyncConfig();
				installManager.RefreshRemoteSource("CrossWire");
			
				installManager.RemoteInstallModule(_swordManager, "CrossWire", "ESV");
				_swordModule = _swordManager.GetModuleByName("ESV");
			}
		}
		
		[TestFixtureTearDown]
		public void TearDown()
		{
			_swordManager.Dispose();
		}
		
		[Test]
		public void Name_Get_Esv()
		{
			//arrange
			//act
			string name =_swordModule.Name;
			
			//assert
			Assert.That (name, Is.EqualTo ("ESV"));
		}
		
		[Test]
		public void Description_Get_DescriptionCorrect()
		{
			//arrange
			//act
			string description =_swordModule.Description;
			
			//assert
			Assert.That (description, Is.EqualTo ("English Standard Version"));
		}
		
		[Test]
		public void Catagory_Get_CatagoryCorrect()
		{
			//arrange
			//act
			string catagory =_swordModule.Category;
			
			//assert
			Assert.That (catagory, Is.EqualTo ("Biblical Texts"));
		}
		
		[Test]
		public void Previous_John3v16_John3v15()
		{
			//arrange
			_swordModule.KeyText = "jn.3.16";
			
			//act
			_swordModule.Prevous();
			
			//assert
			Assert.That (_swordModule.KeyText, Is.EqualTo( "John 3:15"));
		}
		
		[Test]
		public void Next_John3v15_John3v16()
		{
			//arrange
			_swordModule.KeyText = "jn.3.15";
			
			//act
			_swordModule.Next();
			
			//assert
			Assert.That (_swordModule.KeyText, Is.EqualTo( "John 3:16"));
		}
		
		[Test]
		public void Begin_John3v15_Genesis1v1()
		{
			//arrange
			_swordModule.KeyText = "jn.3.15";
			
			//act
			_swordModule.Begin();
			
			//assert
			Assert.That (_swordModule.KeyText, Is.EqualTo( "Genesis 1:1"));
		}
		
		[Test]
		public void RenderHeader_John3v16_ReturnsNonNullOrEmpty()
		{
			//arrange
			_swordModule.KeyText = "jn.3.16";
			
			//act
			string header = _swordModule.RenderHeader;
			
			//assert
			Assert.That (!string.IsNullOrEmpty(header));
		}
		
		[Test]
		public void RawEntry_Get_ContainsVerse()
		{
			//arrange
			_swordModule.KeyText = "jn.3.16";

			//act
			string rawEntry = _swordModule.RawEntry;
			
			//assert
			Assert.That (rawEntry.Contains ("God so loved"));
		}
		
		public void HasSearchFramework_Doesnt_ReturnsFalse()
		{
			//arrange
			//act
			bool hasSearchFramework = _swordModule.HasSearchFramework();
			
			//assert
			Assert.That (hasSearchFramework, Is.False);
		}
	}
}