Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented IDisplayFolderFilter to fix DisplayFolder support #114

Merged
merged 1 commit into from
Sep 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NBi.NUnit/Builder/AbstractStructureBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ protected virtual IEnumerable<CaptionFilter> BuildFilters(AbstractItem item)
yield return new CaptionFilter(Target.Levels, ((ILevelFilter)item).Level);
if (item is IMeasureGroupFilter && !(string.IsNullOrEmpty(((IMeasureGroupFilter)item).MeasureGroup)))
yield return new CaptionFilter(Target.MeasureGroups, ((IMeasureGroupFilter)item).MeasureGroup);
if (item is IDisplayFolderFilter && !(string.IsNullOrEmpty(((IDisplayFolderFilter)item).DisplayFolder)))
yield return new CaptionFilter(Target.DisplayFolders, ((IDisplayFolderFilter)item).DisplayFolder);

//if (item is ISchemaFilter)
// yield return new CaptionFilter(Target.Schemas, ((ISchemaFilter)item).Schema);
if (item is ITableFilter)
Expand Down
89 changes: 84 additions & 5 deletions NBi.Testing/Unit/NUnit/Builder/StructureEquivalentToBuilderTest.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
 #region Using directives
using System;

using System.Linq;
using Moq;
using NBi.Core.Analysis.Request;
using NBi.NUnit.Builder;
using NBi.NUnit.Structure;
using NBi.Xml.Constraints;
Expand All @@ -11,6 +10,8 @@
using NBi.Xml.Systems;
using NUnit.Framework;
using NBi.Core.Structure.Olap;
using NBi.Xml.Items.Filters;

#endregion

namespace NBi.Testing.Unit.NUnit.Builder
Expand Down Expand Up @@ -198,7 +199,7 @@ public void GetSystemUnderTest_CorrectMeasureTarget_Success()
var sut = builder.GetSystemUnderTest();

//Assertion
Assert.That(sut, Is.InstanceOf<OlapCommand>());
Assert.That(sut, Is.InstanceOf<OlapCommand>());
}

//**********************
Expand All @@ -223,9 +224,13 @@ public void GetSystemUnderTest_CorrectDimensionTarget_Success()
//Call the method to test
builder.Build();
var sut = builder.GetSystemUnderTest();

//Assertion
Assert.That(sut, Is.InstanceOf<OlapCommand>());
var command = sut as OlapCommand;
Assert.NotNull(command);
Assert.NotNull(command.Description);
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Perspective"));
Assert.AreEqual(command.Description.Filters.Count(), 1);
}

//**********************
Expand Down Expand Up @@ -310,5 +315,79 @@ public void GetSystemUnderTest_CorrectPropertyTarget_Success()
Assert.That(sut, Is.InstanceOf<OlapCommand>());
}

//**********************
// Test Filters
// IPerspectiveFilter
// IMeasureGroupFilter
// IDisplayFolderFilter
//**********************


[Test]
public void GetSystemUndeTest_CorrectFiltersAppliedOnDescriptionPart1_Success()
{
//Buiding object used during test
var ctrXmlStubFactory = new Mock<EquivalentToXml>();
var ctrXml = ctrXmlStubFactory.Object;

var sutXml = new StructureXml();
sutXml.Item = new MeasuresXml();
sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd();
((IPerspectiveFilter)sutXml.Item).Perspective = "Perspective";
((IMeasureGroupFilter)sutXml.Item).MeasureGroup = "MeasureGroup";
((IDisplayFolderFilter)sutXml.Item).DisplayFolder = "DisplayFolder";
var builder = new StructureEquivalentToBuilder();
builder.Setup(sutXml, ctrXml);
builder.Build();
var sut = builder.GetSystemUnderTest();

//Assertion
Assert.That(sut, Is.InstanceOf<OlapCommand>());

var command = sut as OlapCommand;
Assert.NotNull(command);
Assert.NotNull(command.Description);
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Perspective"));
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "MeasureGroup"));
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "DisplayFolder"));
}


//**********************
// Test Filters
// IDimensionFilter
// IHierarchyFilter
// ILevelFilter
//**********************


[Test]
public void GetSystemUndeTest_CorrectFiltersAppliedOnDescriptionPart2_Success()
{
//Buiding object used during test
var ctrXmlStubFactory = new Mock<EquivalentToXml>();
var ctrXml = ctrXmlStubFactory.Object;

var sutXml = new StructureXml();
sutXml.Item = new PropertiesXml();
sutXml.Item.ConnectionString = ConnectionStringReader.GetAdomd();
((IDimensionFilter)sutXml.Item).Dimension = "Dimension";
((IHierarchyFilter)sutXml.Item).Hierarchy = "Hierarchy";
((ILevelFilter)sutXml.Item).Level = "Level";
var builder = new StructureEquivalentToBuilder();
builder.Setup(sutXml, ctrXml);
builder.Build();
var sut = builder.GetSystemUnderTest();

//Assertion
Assert.That(sut, Is.InstanceOf<OlapCommand>());

var command = sut as OlapCommand;
Assert.NotNull(command);
Assert.NotNull(command.Description);
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Dimension"));
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Hierarchy"));
Assert.IsTrue(command.Description.Filters.Any(f => f.Caption == "Level"));
}
}
}
7 changes: 7 additions & 0 deletions NBi.Xml/Items/Filters/IDisplayFolderFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace NBi.Xml.Items.Filters
{
public interface IDisplayFolderFilter
{
string DisplayFolder { get; set; }
}
}
2 changes: 1 addition & 1 deletion NBi.Xml/Items/HierarchiesXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NBi.Xml.Items
{
public class HierarchiesXml : DimensionsXml, IDimensionFilter
public class HierarchiesXml : DimensionsXml, IDimensionFilter, IDisplayFolderFilter
{
public HierarchiesXml()
{
Expand Down
2 changes: 1 addition & 1 deletion NBi.Xml/Items/HierarchyXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NBi.Xml.Items
{
public class HierarchyXml : DimensionXml, IDimensionFilter
public class HierarchyXml : DimensionXml, IDimensionFilter, IDisplayFolderFilter
{
public HierarchyXml()
{
Expand Down
2 changes: 1 addition & 1 deletion NBi.Xml/Items/MeasureXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NBi.Xml.Items
{
public class MeasureXml : MeasureGroupXml, IMeasureGroupFilter
public class MeasureXml : MeasureGroupXml, IMeasureGroupFilter, IDisplayFolderFilter
{
protected string measureGroup;
[XmlAttribute("measure-group")]
Expand Down
2 changes: 1 addition & 1 deletion NBi.Xml/Items/MeasuresXml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace NBi.Xml.Items
{
public class MeasuresXml : MeasureGroupsXml, IMeasureGroupFilter
public class MeasuresXml : MeasureGroupsXml, IMeasureGroupFilter, IDisplayFolderFilter
{
protected string measureGroup;
[XmlAttribute("measure-group")]
Expand Down
1 change: 1 addition & 0 deletions NBi.Xml/NBi.Xml.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
<Compile Include="InheritanceTestXml.cs" />
<Compile Include="Items\ColumnXml.cs" />
<Compile Include="Items\ColumnsXml.cs" />
<Compile Include="Items\Filters\IDisplayFolderFilter.cs" />
<Compile Include="Items\Filters\IHierarchyFilter.cs" />
<Compile Include="Items\Filters\ILevelFilter.cs" />
<Compile Include="Items\Filters\IMeasureGroupFilter.cs" />
Expand Down