Explorar el Código

Merge pull request #48 from janbernloehr/nunit

Migration from MSTest to NUnit
master
PrzemyslawKlys hace 9 años
padre
commit
4778cd4ea1

+ 5
- 5
UnitTests/AppendBookmark.cs Ver fichero

using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Novacode; using Novacode;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace UnitTests namespace UnitTests
{ {
[TestClass]
[TestFixture]
public class AppendBookmark public class AppendBookmark
{ {
[TestMethod]
[Test]
public void Bookmark_should_be_appended() public void Bookmark_should_be_appended()
{ {
using (var doc = DocX.Create("")) using (var doc = DocX.Create(""))
} }
} }
[TestMethod]
[Test]
public void Bookmark_should_be_named_correctly() public void Bookmark_should_be_named_correctly()
{ {
using (var doc = DocX.Create("")) using (var doc = DocX.Create(""))
} }
} }
[TestMethod]
[Test]
public void Bookmark_should_reference_paragraph() public void Bookmark_should_reference_paragraph()
{ {
using (var doc = DocX.Create("")) using (var doc = DocX.Create(""))

+ 270
- 274
UnitTests/DocXUnitTests.cs
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 5
- 5
UnitTests/InsertAtBookmark.cs Ver fichero

using Novacode; using Novacode;
using System.Linq; using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
namespace UnitTests namespace UnitTests
{ {
[TestClass]
[TestFixture]
public class InsertAtBookmark public class InsertAtBookmark
{ {
[TestMethod]
[Test]
public void Inserting_at_bookmark_should_add_text_in_paragraph() public void Inserting_at_bookmark_should_add_text_in_paragraph()
{ {
using (var document = DocX.Create("")) using (var document = DocX.Create(""))
} }
} }
[TestMethod]
[Test]
public void Inserting_at_bookmark_should_add_text_in_header() public void Inserting_at_bookmark_should_add_text_in_header()
{ {
using (var document = DocX.Create("")) using (var document = DocX.Create(""))
} }
} }
[TestMethod]
[Test]
public void Inserting_at_bookmark_should_add_text_in_footer() public void Inserting_at_bookmark_should_add_text_in_footer()
{ {
using (var document = DocX.Create("")) using (var document = DocX.Create(""))

+ 5
- 10
UnitTests/ReplaceTests.cs Ver fichero

using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using Novacode; using Novacode;
namespace UnitTests namespace UnitTests
{ {
[TestClass]
[TestFixture]
public class RegExTest public class RegExTest
{ {
private readonly Dictionary<string, string> _testPatterns = new Dictionary<string, string> private readonly Dictionary<string, string> _testPatterns = new Dictionary<string, string>
{ "COURT NAME", "Fred Frump" }, { "COURT NAME", "Fred Frump" },
{ "Case Number", "cr-md-2011-1234567" } { "Case Number", "cr-md-2011-1234567" }
}; };
private readonly TestHelper _testHelper;
public RegExTest()
{
_testHelper = new TestHelper();
}
[TestMethod]
[Test]
public void ReplaceText_Can_ReplaceViaFunctionHandler() public void ReplaceText_Can_ReplaceViaFunctionHandler()
{ {
using (var replaceDoc = DocX.Load(_testHelper.DirectoryWithFiles + "ReplaceTests.docx"))
using (var replaceDoc = DocX.Load(Path.Combine(TestHelper.DirectoryWithFiles, "ReplaceTests.docx")))
{ {
foreach (var t in replaceDoc.Tables) foreach (var t in replaceDoc.Tables)
{ {

+ 11
- 8
UnitTests/TestHelper.cs Ver fichero

namespace UnitTests
using System;
using System.IO;
namespace UnitTests
{ {
public class TestHelper
public static class TestHelper
{ {
public string DirectoryWithFiles { get; }
public TestHelper()
static TestHelper()
{ {
var relativeDirectory = new RelativeDirectory(); // prepares the files for testing
relativeDirectory.Up(3);
DirectoryWithFiles = relativeDirectory.Path + @"\UnitTests\documents\";
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
DirectoryWithFiles = Path.Combine(baseDirectory, "documents");
} }
public static string DirectoryWithFiles { get; }
} }
} }

+ 77
- 24
UnitTests/UnitTests.csproj Ver fichero

<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\DocX\bin\Debug\DocX.dll</HintPath> <HintPath>..\DocX\bin\Debug\DocX.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="nunit.framework, Version=3.4.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.4.1\lib\net40\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" /> <Reference Include="System.Configuration" />
<Reference Include="System.Core"> <Reference Include="System.Core">
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="DocXUnitTests.cs" /> <Compile Include="DocXUnitTests.cs" />
<Compile Include="RelativeDirectory.cs" />
<Compile Include="ReplaceTests.cs" /> <Compile Include="ReplaceTests.cs" />
<Compile Include="TestHelper.cs" /> <Compile Include="TestHelper.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="documents\EverybodyHasAHome.docx" />
<None Include="documents\FontFormat.docx" />
<None Include="documents\Hyperlinks.docx" />
<None Include="documents\Images.docx" />
<None Include="documents\MovePicture.docx" />
<None Include="documents\Paragraphs.docx" />
<None Include="documents\ReplaceTests.docx" />
<None Include="documents\Tables.docx" />
<None Include="documents\Template.dotx" />
<None Include="documents\testdoc_OrderedList.docx" />
<None Include="documents\testdoc_OrderedUnorderedLists.docx" />
<None Include="documents\testdoc_SectionsWithHeadingBreaks.docx" />
<None Include="documents\testdoc_SectionsWithSectionBreaks.docx" />
<None Include="documents\testdoc_SectionsWithSectionBreaksMultiParagraph.docx" />
<None Include="documents\testdoc_UnorderedList.docx" />
<None Include="documents\TestParent.docx" />
<None Include="documents\VariousTextFormatting.docx" />
<None Include="documents\EverybodyHasAHome.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\FontFormat.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\Hyperlinks.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\Images.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\LargeTable.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\MovePicture.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\Paragraphs.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\ReplaceTests.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\Tables.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\TableSpecifiedWidths.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\Template.dotx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_OrderedList.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_OrderedUnorderedLists.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_SectionsWithHeadingBreaks.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_SectionsWithSectionBreaks.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_SectionsWithSectionBreaksMultiParagraph.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\testdoc_UnorderedList.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\TestParent.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="documents\VariousTextFormatting.docx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="documents\green.jpg" />
<Content Include="documents\orange.gif" />
<Content Include="documents\purple.png" />
<Content Include="documents\red.bmp" />
<Content Include="documents\yellow.tif" />
<Content Include="documents\green.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="documents\orange.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="documents\purple.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="documents\red.bmp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="documents\yellow.tif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

+ 4
- 0
UnitTests/packages.config Ver fichero

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="3.4.1" targetFramework="net40" />
</packages>

Cargando…
Cancelar
Guardar