Template
57 lines
2.2 KiB
C#
57 lines
2.2 KiB
C#
using NUnit.Framework;
|
|
using Strata.ContinuousImprovement.Biz.StrategicOpportunities.Dtos;
|
|
using Strata.ContinuousImprovement.Biz.StrategicOpportunities.Queries;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using System.Threading.Tasks;
|
|
using VerifyNUnit;
|
|
|
|
namespace Strata.ContinuousImprovement.Biz.Test.Unit.StrategicOpportunities
|
|
{
|
|
[ExcludeFromCodeCoverage]
|
|
[TestFixture, Category("Unit"), Category("CCI")]
|
|
internal class StrategicOpportunityUpdateQueryBuilderTest : StrategicOpportunityTestsBase
|
|
{
|
|
private StrategicOpportunityUpdateQueryBuilder _queryBuilder;
|
|
|
|
private static readonly IEnumerable<string> Rows =
|
|
[
|
|
StrategicOpportunityDetailDimension.System.Value,
|
|
StrategicOpportunityDetailDimension.Entity.Value,
|
|
StrategicOpportunityDetailDimension.Department.Value,
|
|
StrategicOpportunityDetailDimension.ChargeCode.Value,
|
|
];
|
|
|
|
[SetUp]
|
|
public void Setup()
|
|
{
|
|
_queryBuilder = new StrategicOpportunityUpdateQueryBuilder();
|
|
}
|
|
|
|
[Test]
|
|
public async Task BuildUpdateQuery_WithFourAdjustments_GeneratesCorrectSql()
|
|
{
|
|
// Arrange
|
|
const long opportunityId = 42;
|
|
|
|
var adjustments = new List<StrategicOpportunityChargeCodeAdjustment>
|
|
{
|
|
// Root-level adjustment: both units and costs
|
|
new() { NodeKey = "root", UnitsValue = 1000m, CostsValue = 50000m },
|
|
// Entity-level adjustment: costs only
|
|
new() { NodeKey = "101", UnitsValue = null, CostsValue = 20000m },
|
|
// Entity + Department level: units only
|
|
new() { NodeKey = "101|201", UnitsValue = 300m, CostsValue = null },
|
|
// Entity + Department + ChargeCode (lowest level): both units and costs
|
|
new() { NodeKey = "101|201|3001", UnitsValue = 75m, CostsValue = 5000m },
|
|
};
|
|
|
|
// Act
|
|
var result = _queryBuilder.BuildUpdateQuery(adjustments, opportunityId, Rows).Query;
|
|
|
|
// Assert
|
|
await Verifier.Verify(result, VerifySettings);
|
|
}
|
|
}
|
|
}
|