-
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/Support_renaming_a_column_of_a_result-set_(#493)…
…' into develop
- Loading branch information
Showing
17 changed files
with
302 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public interface IRenamingArgs | ||
{ } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public interface IRenamingEngine | ||
{ | ||
ResultSet Execute(ResultSet rs); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
NBi.Core/ResultSet/Alteration/Renaming/NewNameRenamingArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public class NewNameRenamingArgs : IRenamingArgs | ||
{ | ||
public IColumnIdentifier OriginalIdentification { get; set; } | ||
public IScalarResolver<string> NewIdentification { get; set; } | ||
|
||
public NewNameRenamingArgs(IColumnIdentifier originalIdentification, IScalarResolver<string> newIdentification) | ||
=> (OriginalIdentification, NewIdentification) = (originalIdentification, newIdentification); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
NBi.Core/ResultSet/Alteration/Renaming/NewNameRenamingEngine.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using NBi.Core.Scalar.Resolver; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.ResultSet.Alteration.Renaming | ||
{ | ||
class NewNameRenamingEngine : IRenamingEngine | ||
{ | ||
private IColumnIdentifier OriginalIdentification { get; } | ||
private IScalarResolver<string> NewIdentification { get; } | ||
|
||
public NewNameRenamingEngine(IColumnIdentifier originalIdentification, IScalarResolver<string> newIdentification) | ||
=> (OriginalIdentification, NewIdentification) = (originalIdentification, newIdentification); | ||
|
||
public ResultSet Execute(ResultSet rs) | ||
{ | ||
OriginalIdentification.GetColumn(rs.Table).ColumnName = NewIdentification.Execute(); | ||
return rs; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public class RenamingFactory | ||
{ | ||
public IRenamingEngine Instantiate(IRenamingArgs args) | ||
{ | ||
switch(args) | ||
{ | ||
case NewNameRenamingArgs x: return new NewNameRenamingEngine(x.OriginalIdentification, x.NewIdentification); | ||
default: throw new ArgumentException(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
NBi.Testing/Unit/Core/ResultSet/Alteration/Renaming/NewNameRenamingEngineTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using NBi.Core.ResultSet; | ||
using NBi.Core.ResultSet.Alteration.Renaming; | ||
using NBi.Core.ResultSet.Resolver; | ||
using NBi.Core.Scalar.Resolver; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Testing.Unit.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public class RenamingEngineFactoryTest | ||
{ | ||
[Test] | ||
public void Execute_FirstColumnIsText_FirstColumnIsNumeric() | ||
{ | ||
var args = new ObjectsResultSetResolverArgs(new[] { new[] { "100,12", "Alpha" }, new[] { "100", "Beta" }, new[] { "0,1", "Gamma" } }); | ||
var resolver = new ObjectsResultSetResolver(args); | ||
var rs = resolver.Execute(); | ||
|
||
var renamer = new NewNameRenamingEngine( | ||
new ColumnOrdinalIdentifier(1), | ||
new LiteralScalarResolver<string>("myNewName") | ||
); | ||
var newRs = renamer.Execute(rs); | ||
|
||
Assert.That(newRs.Columns[1].ColumnName, Is.EqualTo("myNewName")); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
NBi.Testing/Unit/Core/ResultSet/Alteration/Renaming/RenamingFactoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using NBi.Core.ResultSet; | ||
using NBi.Core.ResultSet.Alteration.Renaming; | ||
using NBi.Core.ResultSet.Resolver; | ||
using NBi.Core.Scalar.Resolver; | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace NBi.Testing.Unit.Core.ResultSet.Alteration.Renaming | ||
{ | ||
public class RenamingFactoryTest | ||
{ | ||
[Test] | ||
public void Instantiate_NewNameRenamingEngineArgs_NewNameRenamingEngineArgs() | ||
{ | ||
var factory = new RenamingFactory(); | ||
var renamer = factory.Instantiate(new NewNameRenamingArgs( | ||
new ColumnOrdinalIdentifier(1), | ||
new LiteralScalarResolver<string>("myNewName") | ||
)); | ||
Assert.That(renamer, Is.Not.Null); | ||
Assert.That(renamer, Is.TypeOf<NewNameRenamingEngine>()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.