-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a service to get ship CII boundaries
- Loading branch information
1 parent
02465ee
commit e42170e
Showing
9 changed files
with
372 additions
and
38 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...ImoCiiCalculator/EtiveMor.OpenImoCiiCalculator.Core.Tests/RatingBoundariesServiceTests.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,77 @@ | ||
using EtiveMor.OpenImoCiiCalculator.Core.Models.Enums; | ||
using EtiveMor.OpenImoCiiCalculator.Core.Models.ShipModels; | ||
using EtiveMor.OpenImoCiiCalculator.Core.Services.Impl; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EtiveMor.OpenImoCiiCalculator.Core.Tests | ||
{ | ||
[TestClass] | ||
public class RatingBoundariesServiceTests | ||
{ | ||
|
||
/// <summary> | ||
/// This method tests that ShipType enum values are considered by the | ||
/// GetBoundaries method. If a new value is added to the Enum, this method | ||
/// will fail until the RatingsBoundariesService is updated to handle the new value. | ||
/// </summary> | ||
[TestMethod] | ||
public void TestGetBoundariesProcessesAllEnumValues() | ||
{ | ||
ShipType[] possibleShipTypeEnums = (ShipType[])Enum.GetValues(typeof(ShipType)); | ||
|
||
for (int i = 0; i < possibleShipTypeEnums.Length; i++) | ||
{ | ||
if (possibleShipTypeEnums[i] == ShipType.UNKNOWN) | ||
{ | ||
// intentionally ignore the UNKNOWN value | ||
continue; | ||
} | ||
var ship = new Ship(possibleShipTypeEnums[i], 250000, 0); | ||
var service = new RatingBoundariesService(); | ||
var boundaries = service.GetBoundaries(ship, 0.5); | ||
|
||
Assert.IsNotNull(boundaries); | ||
} | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Method checks that an exception is thrown when an unknown ShipType | ||
/// is passed to the GetBoundaries method. | ||
/// </summary> | ||
[TestMethod] | ||
public void TestGetBoundariesFailsOnUnknownShipType() | ||
{ | ||
var ship = new Ship(ShipType.UNKNOWN, 250000, 0); | ||
var service = new RatingBoundariesService(); | ||
|
||
Assert.ThrowsException<NotSupportedException>(() => service.GetBoundaries(ship, 0.5)); | ||
} | ||
|
||
|
||
[DataRow(ShipType.BulkCarrier, CapacityUnit.DWT)] | ||
[DataRow(ShipType.GasCarrier, CapacityUnit.DWT)] | ||
[DataRow(ShipType.Tanker, CapacityUnit.DWT)] | ||
[DataRow(ShipType.ContainerShip, CapacityUnit.DWT)] | ||
[DataRow(ShipType.GeneralCargoShip, CapacityUnit.DWT)] | ||
[DataRow(ShipType.RefrigeratedCargoCarrier, CapacityUnit.DWT)] | ||
[DataRow(ShipType.CombinationCarrier, CapacityUnit.DWT)] | ||
[DataRow(ShipType.LngCarrier, CapacityUnit.DWT)] | ||
[DataRow(ShipType.RoRoCargoShipVehicleCarrier, CapacityUnit.GT)] | ||
[DataRow(ShipType.RoRoPassengerShip, CapacityUnit.GT)] | ||
[DataRow(ShipType.CruisePassengerShip, CapacityUnit.GT)] | ||
[TestMethod] | ||
public void TestGrossTonnageCapacityShipTypesAreHandledCorrectly(ShipType shipType, CapacityUnit expectedCapacityUnit) | ||
{ | ||
var ship = new Ship(shipType, 250000, 0); | ||
var service = new RatingBoundariesService(); | ||
var boundaries = service.GetBoundaries(ship, 0.5); | ||
|
||
Assert.AreEqual(expectedCapacityUnit, boundaries.CapacityUnit); | ||
} | ||
} | ||
} |
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
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
11 changes: 11 additions & 0 deletions
11
...nImoCiiCalculator/EtiveMor.OpenImoCiiCalculator.Core/Services/IRatingBoundariesService.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,11 @@ | ||
using EtiveMor.OpenImoCiiCalculator.Core.Models.ShipModels; | ||
using EtiveMor.OpenImoCiiCalculator.Core.Services.Impl; | ||
|
||
namespace EtiveMor.OpenImoCiiCalculator.Core.Services | ||
{ | ||
public interface IRatingBoundariesService | ||
{ | ||
DdVectorDataTableRow GetBoundaries(Ship ship, double requiredCiiInYear); | ||
|
||
} | ||
} |
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.