Skip to content

Commit 666f911

Browse files
authored
Merge branch 'master' into gather-unmapped-cells
2 parents a610c73 + 614cdd2 commit 666f911

13 files changed

Lines changed: 129 additions & 45 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ LinqToExcel.xml
88
*.zip
99
*.nupkg
1010
src/packages/
11+
*.DotSettings.user
12+
*.csproj.user
13+
.vs/
14+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[![Build status](https://ci.appveyor.com/api/projects/status/vdbhqae4b2h86k96?svg=true)](https://ci.appveyor.com/project/mrworkman/linqtoexcel)
2+
[![Open Source Helpers](https://www.codetriage.com/paulyoder/linqtoexcel/badges/users.svg)](https://www.codetriage.com/paulyoder/linqtoexcel)
23

34
# Welcome to the LinqToExcel project
45

src/LinqToExcel.Tests/ColumnMappings_IntegrationTests.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using NUnit.Framework;
44
using System.IO;
55
using log4net.Core;
6-
using System.Data.OleDb;
76

87
namespace LinqToExcel.Tests
98
{
@@ -139,5 +138,19 @@ public void annotated_properties_map_to_columns()
139138
Assert.AreEqual(new DateTime(1988, 7, 26), rival.StartDate, "StartDate");
140139
Assert.AreEqual("N", rival.IsActive, "IsActive");
141140
}
141+
142+
[Test]
143+
public void two_transformations_with_the_same_property_but_in_different_types()
144+
{
145+
_repo.AddTransformation<Transformation1>(x => x.Value, x => x);
146+
_repo.AddTransformation<Transformation2>(x => x.Value, x => x);
147+
148+
var value1 = _repo.Worksheet<Transformation1>("Transformation1").First().Value;
149+
var value2 = _repo.Worksheet<Transformation2>("Transformation2").First().Value;
150+
151+
Assert.AreEqual(1, value1);
152+
Assert.AreEqual("some different value", value2);
153+
}
154+
142155
}
143156
}

src/LinqToExcel.Tests/ConfiguredWorksheetName_IntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void worksheetIndex_of_2_uses_third_table_name_orderedby_name()
5050
[Test]
5151
public void worksheetIndex_too_high_throws_exception()
5252
{
53-
Assert.That(() => from c in ExcelQueryFactory.Worksheet<Company>(8, _excelFileName, new LogManagerFactory())
53+
Assert.That(() => from c in ExcelQueryFactory.Worksheet<Company>(100, _excelFileName, new LogManagerFactory())
5454
select c,
5555
Throws.TypeOf<DataException>());
5656
}
1.5 KB
Binary file not shown.
10.6 KB
Binary file not shown.

src/LinqToExcel.Tests/ExcelQueryFactoryTests.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ public void GetWorksheetNames_returns_worksheet_names()
8080

8181
var worksheetNames = excel.GetWorksheetNames();
8282
Assert.AreEqual(
83-
"ColumnMappings, IMEX Table, Invalid Cast, More Companies, Null Dates, Range1, Sheet1, TrimSpaces",
84-
string.Join(", ", worksheetNames.ToArray()));
83+
"ColumnMappings, IMEX Table, Invalid Cast, More Companies, Null Dates, Range1, Sheet1, Transformation1, Transformation2, TrimSpaces",
84+
string.Join(", ", worksheetNames.ToArray())
85+
);
8586
}
8687

8788
[Test]

src/LinqToExcel.Tests/LinqToExcel.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@
120120
<Compile Include="Row_IntegrationTests.cs" />
121121
<Compile Include="Row_SQLStatement_UnitTests.cs" />
122122
<Compile Include="SQLLogStatements_Helper.cs" />
123+
<Compile Include="Transformations.cs" />
123124
<Compile Include="UnSupportedMethods.cs" />
125+
<Compile Include="WorkSheetNameTests.cs" />
124126
</ItemGroup>
125127
<ItemGroup>
126128
<ProjectReference Include="..\LinqToExcel\LinqToExcel.csproj">
@@ -156,6 +158,9 @@
156158
<None Include="ExcelFiles\NoHeader.xls">
157159
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
158160
</None>
161+
<None Include="ExcelFiles\WorksheetNames.xlsx">
162+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
163+
</None>
159164
<None Include="LinqToExcel.Tests.snk" />
160165
<None Include="packages.config" />
161166
</ItemGroup>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace LinqToExcel.Tests
2+
{
3+
public class Transformation1
4+
{
5+
public int Value { get; set; }
6+
}
7+
8+
public class Transformation2
9+
{
10+
public string Value { get; set; }
11+
}
12+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
using NUnit.Framework;
9+
10+
namespace LinqToExcel.Tests {
11+
12+
[Author("Paul Yoder", "paulyoder@gmail.com")]
13+
[Category("Integration")]
14+
[TestFixture]
15+
public class WorkSheetNameTests {
16+
private String _filesDirectory;
17+
18+
[OneTimeSetUp]
19+
public void Setup() {
20+
var testDirectory = AppDomain.CurrentDomain.BaseDirectory;
21+
_filesDirectory = Path.Combine(testDirectory, "ExcelFiles");
22+
}
23+
24+
[Test]
25+
public void WorkSheetNamesAreDecodedCorrectly() {
26+
var fileName = Path.Combine(_filesDirectory, "WorksheetNames.xlsx");
27+
28+
var workbook = new ExcelQueryFactory(fileName, new LogManagerFactory());
29+
var worksheetNames = workbook.GetWorksheetNames();
30+
31+
CollectionAssert.AreEqual(
32+
new [] {
33+
" ' ",
34+
"$woot$",
35+
"Emb$dded",
36+
"Ends with $'\"",
37+
"Ends with a $",
38+
"Has a $ in it"
39+
},
40+
worksheetNames
41+
);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)