summaryrefslogtreecommitdiff
path: root/bindings/csharp/tests
diff options
context:
space:
mode:
authorDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
committerDaniel Glassey <wdg@debian.org>2015-09-07 11:14:57 +0100
commit7b6c8b08e9d29332dcd0a1029e7421334bfb6f61 (patch)
treedc263ee8b6c923716a8e0fed64756b7af1238dc7 /bindings/csharp/tests
parent7a00574163029c0c2b649878c95d5acbd083564a (diff)
Imported Upstream version 1.7.3+dfsg
Diffstat (limited to 'bindings/csharp/tests')
-rw-r--r--bindings/csharp/tests/AssemblyInfo.cs40
-rw-r--r--bindings/csharp/tests/InstallManagerTests.cs132
-rw-r--r--bindings/csharp/tests/Main.cs25
-rw-r--r--bindings/csharp/tests/ManagerTests.cs111
-rw-r--r--bindings/csharp/tests/ModuleTests.cs162
-rw-r--r--bindings/csharp/tests/Sword.Tests.csproj57
6 files changed, 527 insertions, 0 deletions
diff --git a/bindings/csharp/tests/AssemblyInfo.cs b/bindings/csharp/tests/AssemblyInfo.cs
new file mode 100644
index 0000000..d6b8076
--- /dev/null
+++ b/bindings/csharp/tests/AssemblyInfo.cs
@@ -0,0 +1,40 @@
+// 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.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Sword.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("daniel")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
+// The form "{Major}.{Minor}.*" will automatically update the build and revision,
+// and "{Major}.{Minor}.{Build}.*" will update just the revision.
+
+[assembly: AssemblyVersion("1.0.*")]
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
+
diff --git a/bindings/csharp/tests/InstallManagerTests.cs b/bindings/csharp/tests/InstallManagerTests.cs
new file mode 100644
index 0000000..057c141
--- /dev/null
+++ b/bindings/csharp/tests/InstallManagerTests.cs
@@ -0,0 +1,132 @@
+// 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.Linq;
+
+namespace Sword.Tests
+{
+ [TestFixture]
+ public class InstallManagerTests
+ {
+ InstallManager _installManager;
+
+ [SetUp]
+ public void Setup()
+ {
+ _installManager = new InstallManager("baseDirectory");
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ _installManager.Dispose();
+ }
+
+ [Test]
+ public void SetUserDisclaimerConfirmed_Called_DoesntCrash()
+ {
+ _installManager.SetUserDisclaimerConfirmed();
+ }
+
+ [Test]
+ public void SyncConfig_UserDisclaimerConfirmed_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+
+ //act
+ bool result = _installManager.SyncConfig();
+
+ //assert
+ Assert.That (result, Is.True);
+ }
+
+ [Test]
+ public void SyncConfig_UserDisclaimerNotConfirmed_ReturnsFalse()
+ {
+ //act
+ bool result = _installManager.SyncConfig();
+
+ //assert
+ Assert.That (result, Is.False);
+ }
+
+ [Test]
+ public void RemoteSources_Called_ReturnsRemoteSources()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+
+ //act
+ var remoteSources = _installManager.RemoteSources.ToArray();
+
+ //assert
+ Assert.That (remoteSources.Length > 0);
+ }
+
+ [Test]
+ public void RefreshRemoteSource_Called_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+ string firstSource = _installManager.RemoteSources.First();
+ bool result = _installManager.RefreshRemoteSource(firstSource);
+
+ //act
+ Assert.That (result, Is.True);
+ }
+
+ [Test]
+ public void GetRemoteModInfoList_FirstSource_ReturnsModInfoList()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ _installManager.SyncConfig();
+ string firstSource = _installManager.RemoteSources.First();
+ _installManager.RefreshRemoteSource(firstSource);
+
+ ModInfo[] remoteModInfos;
+ using(Manager manager = new Manager())
+ {
+ //act
+ remoteModInfos = _installManager.GetRemoteModInfoList(manager, firstSource).ToArray();
+ }
+
+ //assert
+ Assert.That (remoteModInfos.Length, Is.GreaterThan(0));
+ }
+
+ [Test]
+ public void RemoteInstallModule_KJV_ReturnsTrue()
+ {
+ //arrange
+ _installManager.SetUserDisclaimerConfirmed();
+ Assert.That (_installManager.SyncConfig(), Is.True);
+ Assert.That (_installManager.RefreshRemoteSource("CrossWire"), Is.True);
+
+ using(Manager manager = new Manager("LocalManager"))
+ {
+ //act
+ bool result = _installManager.RemoteInstallModule(manager, "CrossWire", "KJV");
+
+ //assert
+ Assert.That (result, Is.True);
+ }
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/Main.cs b/bindings/csharp/tests/Main.cs
new file mode 100644
index 0000000..1f96c81
--- /dev/null
+++ b/bindings/csharp/tests/Main.cs
@@ -0,0 +1,25 @@
+// Copyright 2002-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;
+
+namespace Sword.Tests
+{
+ public class MainClass
+ {
+ public static void Main(string[] args)
+ {
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/ManagerTests.cs b/bindings/csharp/tests/ManagerTests.cs
new file mode 100644
index 0000000..6f71b33
--- /dev/null
+++ b/bindings/csharp/tests/ManagerTests.cs
@@ -0,0 +1,111 @@
+// 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;
+using System.Linq;
+
+namespace Sword.Tests
+{
+ [TestFixture]
+ public class ManagerTests
+ {
+ Manager _manager;
+
+ [TestFixtureSetUp]
+ public void Setup()
+ {
+ _manager = new Manager();
+ }
+
+ [TestFixtureTearDown]
+ public void TearDown()
+ {
+ _manager.Dispose();
+ }
+
+ [Test]
+ public void Version_Get_ReturnsAVersion()
+ {
+ //act
+ string swordVersion = _manager.Version;
+
+ //assert
+ Version version;
+ Assert.That (Version.TryParse(swordVersion, out version));
+ }
+
+ [Test]
+ public void PrefixPath_Get_ReturnsValidPath()
+ {
+ //act
+ string prefixPath = _manager.PrefixPath;
+
+ //assert
+ Assert.That (Directory.Exists(prefixPath), Is.True);
+ }
+
+ [Test]
+ public void ConfigPath_Get_ReturnsValidPath()
+ {
+ //act
+ string configPath = _manager.ConfigPath;
+
+ //assert
+ Assert.That (Directory.Exists(configPath), Is.True);
+ }
+
+ [Test]
+ public void SetCipherKey_Called_DoesntCrash()
+ {
+ //act
+ _manager.SetCipherKey("ESV", new byte[32]);
+ }
+
+ [Test]
+ public void Javascript_Set_DoesntCrash()
+ {
+ //act
+ _manager.Javascript = true;
+ }
+
+ [Test]
+ public void AvailableLocales_Get_DoesntCrash()
+ {
+ //act
+ var availableLocales = _manager.AvailableLocales.ToArray();
+
+ //Assert
+ Assert.That (availableLocales[0].Contains("en"));
+ }
+
+ [Test]
+ public void DefaultLocale_SetToEn_DoesntCrash()
+ {
+ //act
+ _manager.DefaultLocale = "en";
+ }
+
+ [Test]
+ public void Translate_EnglishToEnglish_ReturnsOrginal()
+ {
+ //act
+ var result = _manager.Translate("love", "en");
+
+ //assert
+ Assert.That (result, Is.EqualTo("love"));
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/ModuleTests.cs b/bindings/csharp/tests/ModuleTests.cs
new file mode 100644
index 0000000..71cbea8
--- /dev/null
+++ b/bindings/csharp/tests/ModuleTests.cs
@@ -0,0 +1,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);
+ }
+ }
+}
+
diff --git a/bindings/csharp/tests/Sword.Tests.csproj b/bindings/csharp/tests/Sword.Tests.csproj
new file mode 100644
index 0000000..1e44fda
--- /dev/null
+++ b/bindings/csharp/tests/Sword.Tests.csproj
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>10.0.0</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{72212684-1186-4F68-8FBD-BDBFDB8CC9BC}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <RootNamespace>Sword.Tests</RootNamespace>
+ <AssemblyName>CSSword.Tests</AssemblyName>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug</OutputPath>
+ <DefineConstants>DEBUG;</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ <Commandlineparameters>ESV jn.3.16</Commandlineparameters>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Release</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <Externalconsole>true</Externalconsole>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="nunit.core, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Private>False</Private>
+ <Package>mono-nunit</Package>
+ </Reference>
+ <Reference Include="nunit.framework, Version=2.5.10.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77">
+ <Private>False</Private>
+ <Package>mono-nunit</Package>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AssemblyInfo.cs" />
+ <Compile Include="ModuleTests.cs" />
+ <Compile Include="ManagerTests.cs" />
+ <Compile Include="InstallManagerTests.cs" />
+ <Compile Include="Main.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <ItemGroup>
+ <ProjectReference Include="..\Sword.csproj">
+ <Project>{EFEE3557-86F2-4E46-AF7E-8BADEE240764}</Project>
+ <Name>Sword</Name>
+ </ProjectReference>
+ </ItemGroup>
+</Project> \ No newline at end of file