using NUnit.Framework;
using StructureHelperCommon.Infrastructures.Enums;
using StructureHelperCommon.Infrastructures.Settings;
using StructureHelperCommon.Models.Materials;
using StructureHelperLogics.Models.Materials;

namespace StructureHelperTests.UnitTests.MaterialTests
{
    public class MaterialStrengthTest
    {
        [TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 339130434.78260875d, 339130434.78260875d)]
        [TestCase(HeadmaterialType.Reinforcement400, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 390000000d, 390000000d)]
        [TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 400000000.0d, 434782608.69565225d)]
        [TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 434782608.69565225d, 434782608.69565225d)]
        [TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
        [TestCase(HeadmaterialType.Reinforcement500, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 5e8d, 5e8d)]
        [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.ShortTerm, 22199999.999999996d, 1395297.0017909051d)]
        [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.ULS, CalcTerms.LongTerm, 19980000.0d, 1255767.3016118146d)]
        [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.ShortTerm, 28860000.0d, 2092945.5026863578d)]
        [TestCase(HeadmaterialType.Concrete40, CodeTypes.SP63_2018, LimitStates.SLS, CalcTerms.LongTerm, 28860000.0d, 2092945.5026863578d)]
        public void Run_ShouldPass(HeadmaterialType headmaterialType, CodeTypes code, LimitStates limitState, CalcTerms calcTerm, double expectedCompressive, double expectedTensile)
        {
            //Arrange
            ProgramSetting.NatSystem = NatSystems.RU;
            var material = HeadMaterialFactory.GetHeadMaterial(headmaterialType);
            var libMaterial = material.HelperMaterial as ILibMaterial;
            //Act
            var compressive = libMaterial.GetStrength(limitState, calcTerm).Compressive;
            var tensile = libMaterial.GetStrength(limitState, calcTerm).Tensile;
            //Assert
            Assert.That(compressive, Is.EqualTo(expectedCompressive).Within(1d));
            Assert.That(tensile, Is.EqualTo(expectedTensile).Within(1d));
        }
    }
}
