37 changed files with 1665 additions and 192 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// 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 ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
|
||||
namespace XmlEditor.Tests.Schema |
||||
{ |
||||
[TestFixture] |
||||
public class SubstitutionGroupTests : SchemaTestFixtureBase |
||||
{ |
||||
string namespaceURI = "http://www.w3.org/1999/XSL/Transform"; |
||||
|
||||
protected override string GetSchema() |
||||
{ |
||||
return |
||||
"<xs:schema " + |
||||
" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"" + |
||||
" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"" + |
||||
" targetNamespace=\"http://www.w3.org/1999/XSL/Transform\"" + |
||||
" elementFormDefault=\"qualified\">\r\n" + |
||||
" <xs:element name=\"stylesheet\" substitutionGroup=\"xsl:transform\"/>\r\n" + |
||||
"</xs:schema>"; |
||||
} |
||||
|
||||
[Test] |
||||
public void GetChildElementCompletion_ParentElementIsSubstitutionGroupButNoCorrespondingElementInSchema_NullReferenceExceptionIsNotThrown() |
||||
{ |
||||
var path = new XmlElementPath(); |
||||
path.AddElement(new QualifiedName("stylesheet", namespaceURI)); |
||||
|
||||
XmlCompletionItemCollection items = SchemaCompletion.GetChildElementCompletion(path); |
||||
|
||||
Assert.AreEqual(0, items.Count); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,48 @@
@@ -0,0 +1,48 @@
|
||||
// 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 ICSharpCode.XmlEditor; |
||||
using NUnit.Framework; |
||||
using XmlEditor.Tests.Utils; |
||||
|
||||
namespace XmlEditor.Tests.Schema |
||||
{ |
||||
[TestFixture] |
||||
public class XsltSchemaTests |
||||
{ |
||||
string namespaceURI = "http://www.w3.org/1999/XSL/Transform"; |
||||
XmlSchemaCompletion schemaCompletion; |
||||
|
||||
[TestFixtureSetUp] |
||||
public void SetUp() |
||||
{ |
||||
schemaCompletion = new XmlSchemaCompletion(ResourceManager.ReadXsltSchema()); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetChildElementCompletion_StylesheetElement_SubstitutionGroupUsedForTemplateAndTemplateElementReturned() |
||||
{ |
||||
var path = new XmlElementPath(); |
||||
path.AddElement(new QualifiedName("stylesheet", namespaceURI)); |
||||
|
||||
XmlCompletionItemCollection completionItems = schemaCompletion.GetChildElementCompletion(path); |
||||
bool contains = completionItems.Contains("template"); |
||||
|
||||
Assert.IsTrue(contains); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetAttributeCompletion_TemplateElementIsChildOfStylesheetElement_SubstitutionGroupUsedForTemplateAndMatchAttributeReturned() |
||||
{ |
||||
var path = new XmlElementPath(); |
||||
path.AddElement(new QualifiedName("stylesheet", namespaceURI)); |
||||
path.AddElement(new QualifiedName("template", namespaceURI)); |
||||
|
||||
XmlCompletionItemCollection completionItems = schemaCompletion.GetAttributeCompletion(path); |
||||
bool contains = completionItems.Contains("match"); |
||||
|
||||
Assert.IsTrue(contains); |
||||
} |
||||
} |
||||
} |
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,45 @@
@@ -0,0 +1,45 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 06.02.2013 |
||||
* Time: 20:18 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using SimpleExpressionEvaluator.Utilities; |
||||
|
||||
namespace SimpleExpressionEvaluator.Compilation.Functions |
||||
{ |
||||
/// <summary>
|
||||
/// DateSubtract (endDate,startDate)
|
||||
/// </summary>
|
||||
public class DateSubtract: Function<TimeSpan> |
||||
{ |
||||
|
||||
protected override int ExpectedArgumentCount |
||||
{ |
||||
get{return 2;} |
||||
} |
||||
|
||||
|
||||
protected override TimeSpan EvaluateFunction(object[] args) |
||||
{ |
||||
|
||||
args[0] = args[0] == null ? DateTime.Today : TypeNormalizer.EnsureType(args[0], typeof (DateTime)); |
||||
|
||||
args[1] = args[1] == null ? DateTime.Today : TypeNormalizer.EnsureType(args[1], typeof (DateTime)); |
||||
|
||||
var endDate = (DateTime) args[0]; |
||||
if (endDate == DateTime.MinValue) { |
||||
endDate = DateTime.Today; |
||||
} |
||||
var startDate = (DateTime) args[1]; |
||||
if (startDate == DateTime.MinValue) |
||||
startDate = DateTime.Today; |
||||
|
||||
return endDate.Subtract(startDate); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@ -0,0 +1,138 @@
@@ -0,0 +1,138 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 13.02.2013 |
||||
* Time: 19:48 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Globalization; |
||||
using ICSharpCode.Reports.Core.BaseClasses.Printing; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Reports.Core.Test.Printing |
||||
{ |
||||
[TestFixture] |
||||
public class FormattingFixture |
||||
{ |
||||
private const string stringType = "System.String"; |
||||
private const string dateTimetype = "System.DateTime"; |
||||
private const string nullValue ="NullValue"; |
||||
[Test] |
||||
public void String_Is_Not_Formatted() |
||||
{ |
||||
string toFormat = "Hello World"; |
||||
string format = "dd/MM/yy"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,stringType,nullValue); |
||||
Assert.That(result,Is.EqualTo(toFormat)); |
||||
} |
||||
|
||||
[Test] |
||||
public void Empty_Input_Returns_NullValue() |
||||
{ |
||||
string toFormat = string.Empty;; |
||||
string format = "dd/MM/yy"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,stringType,nullValue); |
||||
Assert.That(result,Is.EqualTo(nullValue)); |
||||
} |
||||
|
||||
#region DateTime
|
||||
|
||||
[Test] |
||||
public void DateTime_dd_MM_YY () |
||||
{ |
||||
string toFormat = "2012/02/12"; |
||||
string format = "dd.MM.yy"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.EqualTo("12.02.12")); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void TypeDateTimeOfResultIsString() |
||||
{ |
||||
string toFormat = "2012/02/12"; |
||||
string format = "dd.MM.yy"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.TypeOf(typeof(string))); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void ConvertResultToDateTime() |
||||
{ |
||||
DateTime date; |
||||
string toFormat = "2012/02/12"; |
||||
string format = "dd.MM.yy"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
|
||||
|
||||
bool valid = DateTime.TryParse(toFormat, out date); |
||||
|
||||
Assert.That(valid,Is.True); |
||||
Assert.That(date,Is.EqualTo(new DateTime(2012,02,12))); |
||||
} |
||||
|
||||
#endregion
|
||||
|
||||
#region TimeSpan
|
||||
|
||||
[Test] |
||||
public void TimeSpan_HH_mm_ss () |
||||
{ |
||||
string toFormat = "5:50:10"; |
||||
string format = "HH:mm:ss"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.EqualTo("05:50:10")); |
||||
} |
||||
|
||||
[Test] |
||||
public void TimeSpan_H_mm_ss () |
||||
{ |
||||
string toFormat = "5:50:10"; |
||||
string format = "H:mm:ss"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.EqualTo("5:50:10")); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void TimeSpan_D_H_mm_ss () |
||||
{ |
||||
string toFormat = "1,5:50:10"; |
||||
string format = "H:mm:ss"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.EqualTo("1,5:50:10")); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void TypeOfTimeSpanResultIsString() |
||||
{ |
||||
string toFormat = "5,50,10"; |
||||
string format = "H:mm:ss"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
Assert.That(result,Is.TypeOf(typeof(string))); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void ConvertResultToTimeSpan() |
||||
{ |
||||
TimeSpan time; |
||||
string toFormat = "5:50:10"; |
||||
string format = "H:mm:ss"; |
||||
var result = StandardFormatter.FormatOutput(toFormat,format,dateTimetype,nullValue); |
||||
|
||||
bool valid = TimeSpan.TryParseExact(result, |
||||
"c", |
||||
CultureInfo.CurrentCulture, |
||||
out time); |
||||
Assert.That(valid,Is.True); |
||||
Assert.That(time,Is.EqualTo(new TimeSpan(5,50,10))); |
||||
} |
||||
|
||||
#endregion
|
||||
} |
||||
} |
||||
@ -0,0 +1,82 @@
@@ -0,0 +1,82 @@
|
||||
// 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 ICSharpCode.Reports.Expressions.ReportingLanguage; |
||||
using NUnit.Framework; |
||||
using SimpleExpressionEvaluator; |
||||
|
||||
namespace ICSharpCode.Reports.Core.Test.ReportingLanguage.LanguageTests |
||||
{ |
||||
[TestFixture] |
||||
public class DateTimeFunctionsFixture |
||||
{ |
||||
|
||||
[Test] |
||||
public void Can_Compile_Function() |
||||
{ |
||||
const string expression = "today()"; |
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today)); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void Can_Compile_Expr_With_Generic_Return() |
||||
{ |
||||
const string expression = "Today()"; |
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today)); |
||||
} |
||||
|
||||
[Test] |
||||
public void Can_Compile_DateAdd() |
||||
{ |
||||
const string expression = "dateAdd(today(),d,1)"; |
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today.AddDays(1))); |
||||
} |
||||
|
||||
[Test] |
||||
public void Can_Compile_DateDiff () |
||||
{ |
||||
const string expression = "dateSubtract('10.02.2013','09.02.2013')"; |
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(new TimeSpan(1,0,0,0).Duration())); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void Can_Compile_DateDiff_Start_Greater_End () |
||||
{ |
||||
const string expression = "dateSubtract('09.02.2013','10.02.2013')"; |
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(new TimeSpan(1,0,0,0))); |
||||
} |
||||
|
||||
[Test] |
||||
public void Can_Compile_DateDiff_Include_Hours_Minutes() |
||||
{ |
||||
|
||||
// Example found at:
|
||||
// http://msdn.microsoft.com/en-us/library/ae6246z1.aspx
|
||||
|
||||
System.DateTime date1 = new System.DateTime(1996, 6, 3, 22, 15, 0); |
||||
System.DateTime date2 = new System.DateTime(1996, 12, 6, 13, 2, 0); |
||||
// diff1 gets 185 days, 14 hours, and 47 minutes.
|
||||
System.TimeSpan diff1 = date2.Subtract(date1); |
||||
|
||||
const string expression = "dateSubtract('1996.12.6 13:2:0','1996.6.3 22:15:0')"; |
||||
|
||||
IExpression expr = CreateExpression(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(diff1)); |
||||
} |
||||
|
||||
|
||||
private static IExpression CreateExpression (string expression) |
||||
{ |
||||
var compiler = new ReportingLanguageCompiler(); |
||||
return compiler.CompileExpression<object>(expression); |
||||
} |
||||
} |
||||
} |
||||
@ -1,43 +0,0 @@
@@ -1,43 +0,0 @@
|
||||
// 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 ICSharpCode.Reports.Expressions.ReportingLanguage; |
||||
using NUnit.Framework; |
||||
using SimpleExpressionEvaluator; |
||||
|
||||
namespace ICSharpCode.Reports.Core.Test.ReportingLanguage.LanguageTests |
||||
{ |
||||
[TestFixture] |
||||
public class FunctionsFixture |
||||
{ |
||||
|
||||
[Test] |
||||
public void Can_Compile_Function() |
||||
{ |
||||
const string expression = "today()"; |
||||
var compiler = new ReportingLanguageCompiler(); |
||||
IExpression expr = compiler.CompileExpression<DateTime>(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today)); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void Can_Compile_Expr_With_Generic_Return() |
||||
{ |
||||
const string expression = "Today()"; |
||||
var compiler = new ReportingLanguageCompiler(); |
||||
IExpression expr = compiler.CompileExpression<object>(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today)); |
||||
} |
||||
|
||||
[Test] |
||||
public void Can_Compile_DateAdd() |
||||
{ |
||||
const string expression = "dateAdd(today(),d,1)"; |
||||
var compiler = new ReportingLanguageCompiler(); |
||||
IExpression expr = compiler.CompileExpression<object>(expression); |
||||
Assert.That(expr.Evaluate(null), Is.EqualTo(DateTime.Today.AddDays(1))); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue