Files
Thom Lamb 2cd6df6481 Initial commit of the ClosedXML library
Establishes the foundational structure, core Excel functionality, and tooling.

- Implements base components for cells, ranges, columns, and rows.
- Integrates a custom calculation engine with a wide range of Excel functions.
- Adds comprehensive support for styling, conditional formatting, data validation, comments, pictures, and charts.
- Configures build setup, project metadata (NuGet), and developer guidelines.
- Includes editor and Git attributes for consistent code style and line endings.
2026-06-23 11:02:53 -05:00

64 lines
1.8 KiB
C#

using ClosedXML.Excel;
using NUnit.Framework;
using System;
namespace ClosedXML_Tests.Excel.CalcEngine
{
[TestFixture]
public class LogicalTests
{
[Test]
public void If_2_Params_true()
{
Object actual = XLWorkbook.EvaluateExpr(@"if(1 = 1, ""T"")");
Assert.AreEqual("T", actual);
}
[Test]
public void If_2_Params_false()
{
Object actual = XLWorkbook.EvaluateExpr(@"if(1 = 2, ""T"")");
Assert.AreEqual(false, actual);
}
[Test]
public void If_3_Params_true()
{
Object actual = XLWorkbook.EvaluateExpr(@"if(1 = 1, ""T"", ""F"")");
Assert.AreEqual("T", actual);
}
[Test]
public void If_3_Params_false()
{
Object actual = XLWorkbook.EvaluateExpr(@"if(1 = 2, ""T"", ""F"")");
Assert.AreEqual("F", actual);
}
[Test]
public void If_Comparing_Against_Empty_String()
{
Object actual;
actual = XLWorkbook.EvaluateExpr(@"if(date(2016, 1, 1) = """", ""A"",""B"")");
Assert.AreEqual("B", actual);
actual = XLWorkbook.EvaluateExpr(@"if("""" = date(2016, 1, 1), ""A"",""B"")");
Assert.AreEqual("B", actual);
actual = XLWorkbook.EvaluateExpr(@"if("""" = 123, ""A"",""B"")");
Assert.AreEqual("B", actual);
actual = XLWorkbook.EvaluateExpr(@"if("""" = """", ""A"",""B"")");
Assert.AreEqual("A", actual);
}
[Test]
public void If_Case_Insensitivity()
{
Object actual;
actual = XLWorkbook.EvaluateExpr(@"IF(""text""=""TEXT"", 1, 2)");
Assert.AreEqual(1, actual);
}
}
}