This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 771
/
ConcatFieldsFixture.cs
89 lines (71 loc) · 2.41 KB
/
ConcatFieldsFixture.cs
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
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Data;
using ICSharpCode.Reports.Core.BaseClasses;
using ICSharpCode.Reports.Core.Test.TestHelpers;
using ICSharpCode.Reports.Expressions.ReportingLanguage;
using NUnit.Framework;
namespace ICSharpCode.Reports.Core.Test.ReportingLanguage.IntegrationTests
{
[TestFixture]
public class ConcatFieldsFixture
{
private IExpressionEvaluatorFacade evaluator;
private DataTable testTable;
private SinglePage singlePage;
private IDataManager dataManager;
[Test]
public void Return_FieldName_If_DataNavigator_Invalid()
{
const string expression = "=Fields!Name";
this.singlePage.IDataNavigator.Reset();
Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo("Name"));
}
[Test]
public void Misspelled_Simple_FieldReference()
{
const string expression = "=fields!Name";
Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo("Name"));
}
[Test]
public void Evaluate_If_DataNavigator_Is_Invalid()
{
const string expression = "=Fields!Name";
this.singlePage.IDataNavigator.MoveNext();
DataRow row = testTable.Rows[0];
string testVal = row["Name"].ToString();
Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo(testVal));
}
[Test]
public void Unkown_ColumnName ()
{
const string expression = "=Fields!Unknown";
Assert.That(this.evaluator.Evaluate(expression), Is.EqualTo("Unknown"));
}
[Test]
public void Extract_Field_ByName ()
{
const string expression = "=Fields!Name";
DataRow r = testTable.Rows[0];
string result = r["Name"].ToString();
Assert.That(this.evaluator.Evaluate(expression),
Is.EqualTo(result));
}
[TestFixtureSetUp]
public void Init()
{
this.singlePage = TestHelper.CreateSinglePage();
this.evaluator = new ExpressionEvaluatorFacade(this.singlePage);
AggregateFuctionHelper ah = new AggregateFuctionHelper();
this.testTable = ah.AggregateTable;
this.dataManager = ICSharpCode.Reports.Core.DataManager.CreateInstance(this.testTable, new ReportSettings());
this.singlePage.IDataNavigator = this.dataManager.GetNavigator;
}
[TestFixtureTearDown]
public void Dispose()
{
// TODO: Add tear down code.
}
}
}