public void LayerCollection_A2_CountAll()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layers active.wflx");

                WFInt.OpenFile(sfile);

                short Actual = WFInt.WellModel.AddRef().Layers.AddRef().CountAll;

                //short Expected = 2;

                WFInt.EndWellFlo();
                //Assert.AreEqual(Expected, Actual);
                AreEqual("CountAll", Actual);
            }
        }
        public void LayerCollection_A3_Item()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer.wflx");

                WFInt.OpenFile(sfile);

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().DietzFactor, 1);

                //double Expected = 31.6;

                WFInt.EndWellFlo();
                //Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
                AreEqual("DietzFactor", 31.6);
            }
        }
        public void LayerRate_Set4_A1_GetAt_Name()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer rate - set 4.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 21780.34;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                int i = 0;

                string Actual = WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().GetAt(i).AddRef().Name;

                string Expected = "Layer 1";

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);
            }
        }
        public void LayerRate_Set3_A2_Item_WaterRate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\one layer active and one is inactive.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 92987.929;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                string sName = "Layer 2";

                double Actual = Math.Round(WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Item(sName).AddRef().WaterRate, 2);

                double Expected = 23246.98;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void LayerRate_Set2_A5_RemoveAll()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer.wflx");

                string sfile2 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer_RemoveAll.wflx");

                WFInt.OpenFile(sfile1);

                WFInt.SaveFile(sfile2);

                double dRate = 37100;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().RemoveAll();

                WFInt.SaveFile(sfile2);

                WFInt.OpenFile(sfile2);

                int Actual = WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Count;

                int Expected = 0;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);
            }
        }
        public void Layer_A3_PartingPressure()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\injection well.wflx");

                WFInt.OpenFile(sfile1);

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().PartingPressure, 0);

                double Expected = 7000;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void LayerRate_Set4_A3_Count()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer rate - set 4.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 92987.929;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                int Actual = WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Count;

                int Expected = 1;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);
            }
        }
        public void Layer_B2_SetTestPoint1Data_TestPoint1Rate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\test rate.wflx");

                string sfileOutput2 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\SetTestPoint1Data_AfterSetting_2.wflx");

                WFInt.OpenFile(sfile);

                double dBHP = 4500;
                double dQLiq = 1050;

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().SetTestPoint1Data(dBHP, dQLiq);

                WFInt.SaveFile(sfileOutput2);

                double Actual = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().TestPoint1Rate;

                double Expected = 1050;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_New_VogelPCoefficient()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layers active.wflx");

                WFInt.OpenFile(sfile1);

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(2).AddRef().VogelPCoefficient, 2);

                double Expected = 0.2;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_A9_GetRelPermTable_225_A()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\real perm table.wflx");

                WFInt.OpenFile(sfile1);

                Array psaRelParms3 = Array.CreateInstance(typeof(double), 3, 3, 10);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetRelPermTable(ref psaRelParms3);

                string i = psaRelParms3.GetValue(2, 1, 0).ToString();

                double Actual = System.Convert.ToDouble(i);

                double Expected = 0.0000085;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_B1_SetTabulatedIPRData()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\no tabulated data.wflx");

                string sfileOutputSetTabulatedIPRData = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\OutputSetTabulatedIPRData.wflx");

                WFInt.OpenFile(sfile1);

                int indexArray = 21;

                Array psaPress1 = Array.CreateInstance(typeof(double), indexArray);
                Array psaFlowRate1 = Array.CreateInstance(typeof(double), indexArray);
                Array psaPhaseRate1 = Array.CreateInstance(typeof(double), indexArray);
                Array psaWaterRate1 = Array.CreateInstance(typeof(double), indexArray);

                psaPress1.SetValue(14.650, 0);
                psaPress1.SetValue(416.418, 1);
                psaPress1.SetValue(818.185, 2);
                psaPress1.SetValue(1219.953, 3);
                psaPress1.SetValue(1621.720, 4);
                psaPress1.SetValue(2023.488, 5);
                psaPress1.SetValue(2425.255, 6);
                psaPress1.SetValue(2827.022, 7);
                psaPress1.SetValue(3228.790, 8);
                psaPress1.SetValue(3630.558, 9);
                psaPress1.SetValue(4032.325, 10);
                psaPress1.SetValue(4434.093, 11);
                psaPress1.SetValue(4835.860, 12);
                psaPress1.SetValue(5237.637, 13);
                psaPress1.SetValue(5639.395, 14);
                psaPress1.SetValue(6041.163, 15);
                psaPress1.SetValue(6442.930, 16);
                psaPress1.SetValue(6844.698, 17);
                psaPress1.SetValue(7246.465, 18);
                psaPress1.SetValue(7648.233, 19);
                psaPress1.SetValue(8050.000, 20);

                psaFlowRate1.SetValue(0.1239, 0);
                psaFlowRate1.SetValue(0.1177, 1);
                psaFlowRate1.SetValue(0.1115, 2);
                psaFlowRate1.SetValue(0.1053, 3);
                psaFlowRate1.SetValue(0.0991, 4);
                psaFlowRate1.SetValue(0.0929, 5);
                psaFlowRate1.SetValue(0.0867, 6);
                psaFlowRate1.SetValue(0.0805, 7);
                psaFlowRate1.SetValue(0.0743, 8);
                psaFlowRate1.SetValue(0.0681, 9);
                psaFlowRate1.SetValue(0.0620, 10);
                psaFlowRate1.SetValue(0.0558, 11);
                psaFlowRate1.SetValue(0.0496, 12);
                psaFlowRate1.SetValue(0.0434, 13);
                psaFlowRate1.SetValue(0.0372, 14);
                psaFlowRate1.SetValue(0.0310, 15);
                psaFlowRate1.SetValue(0.0248, 16);
                psaFlowRate1.SetValue(0.0186, 17);
                psaFlowRate1.SetValue(0.0124, 18);
                psaFlowRate1.SetValue(0.0062, 19);
                psaFlowRate1.SetValue(0, 20);

                psaPhaseRate1.SetValue(6666.6665, 0);
                psaPhaseRate1.SetValue(6666.6665, 1);
                psaPhaseRate1.SetValue(6666.6665, 2);
                psaPhaseRate1.SetValue(6666.6665, 3);
                psaPhaseRate1.SetValue(6666.6665, 4);
                psaPhaseRate1.SetValue(6666.6665, 5);
                psaPhaseRate1.SetValue(6666.6665, 6);
                psaPhaseRate1.SetValue(6666.6665, 7);
                psaPhaseRate1.SetValue(6666.6665, 8);
                psaPhaseRate1.SetValue(6666.6665, 9);
                psaPhaseRate1.SetValue(6666.6665, 10);
                psaPhaseRate1.SetValue(6666.6665, 11);
                psaPhaseRate1.SetValue(6666.6665, 12);
                psaPhaseRate1.SetValue(6666.6665, 13);
                psaPhaseRate1.SetValue(6666.6665, 14);
                psaPhaseRate1.SetValue(6666.6665, 15);
                psaPhaseRate1.SetValue(6666.6665, 16);
                psaPhaseRate1.SetValue(6666.6665, 17);
                psaPhaseRate1.SetValue(6666.6665, 18);
                psaPhaseRate1.SetValue(6666.6665, 19);
                psaPhaseRate1.SetValue(6666.6665, 20);

                psaWaterRate1.SetValue(0.5000, 0);
                psaWaterRate1.SetValue(0.5000, 1);
                psaWaterRate1.SetValue(0.5000, 2);
                psaWaterRate1.SetValue(0.5000, 3);
                psaWaterRate1.SetValue(0.5000, 4);
                psaWaterRate1.SetValue(0.5000, 5);
                psaWaterRate1.SetValue(0.5000, 6);
                psaWaterRate1.SetValue(0.5000, 7);
                psaWaterRate1.SetValue(0.5000, 8);
                psaWaterRate1.SetValue(0.5000, 9);
                psaWaterRate1.SetValue(0.5000, 10);
                psaWaterRate1.SetValue(0.5000, 11);
                psaWaterRate1.SetValue(0.5000, 12);
                psaWaterRate1.SetValue(0.5000, 13);
                psaWaterRate1.SetValue(0.5000, 14);
                psaWaterRate1.SetValue(0.5000, 15);
                psaWaterRate1.SetValue(0.5000, 16);
                psaWaterRate1.SetValue(0.5000, 17);
                psaWaterRate1.SetValue(0.5000, 18);
                psaWaterRate1.SetValue(0.5000, 19);
                psaWaterRate1.SetValue(0.5000, 20);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().SetTabulatedIPRData(indexArray, ref psaPress1, ref psaFlowRate1, ref psaPhaseRate1, ref psaWaterRate1);

                WFInt.SaveFile(sfileOutputSetTabulatedIPRData);

                short Actual = WFInt.ErrorStatus;

                short Expected = 0;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);

            }
        }
        public void Layer_A8_GetRelPermParmsGasOil_3_psaExp_1()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\real perm.wflx");

                WFInt.OpenFile(sfile1);

                Array psaRelParms2 = Array.CreateInstance(typeof(double), 2);
                Array psaIrrSat2 = Array.CreateInstance(typeof(double), 2);
                Array psaExp2 = Array.CreateInstance(typeof(double), 2);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetRelPermParmsGasOil(ref psaRelParms2, ref psaIrrSat2, ref psaExp2);

                string i = psaExp2.GetValue(1).ToString();

                double Actual = Math.Round(System.Convert.ToDouble(i), 2);

                double Expected = 1.7;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_A5_CalcBHPOfOilWell()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\oil well BHP.wflx");

                WFInt.OpenFile(sfile1);

                double fQOil = 2696.4;
                double fGOR = 500;
                double fWCT = 0.25;
                double fTHP = 100;

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().CalcBHPOfOilWell(fQOil, fGOR, fWCT, fTHP), 3);

                double Expected1 = 4043.613;
                double Expected = Math.Round(Expected1, 3);

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_A4_CalcBHPOfGasWell()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\gas well BHP.wflx");

                WFInt.OpenFile(sfile1);

                double fQGas = 1.98;
                double fCGR = 0;
                double fWGR = 350;
                double fTHP = 200;

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().CalcBHPOfGasWell(fQGas, fCGR, fWGR, fTHP), 2);

                double Expected = 378.71;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void LayerRate_Set4_A1_GetAt_OilRate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer rate - set 4.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 21780.34;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                int i = 0;

                double Actual = Math.Round(WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().GetAt(i).AddRef().OilRate, 2);

                double Expected = 16335.25;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void LayerRate_Set2_A1_Add()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer.wflx");
                //string sfile2 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer_Save1.wflx");(model doesnot exist!!)

                WFInt.OpenFile(sfile1);

                double dRate = 37100;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                int Count = WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Count;

                string sName = "Layer 2";

                WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Add(sName);

                int Actual = WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Count;

                int Expected = 2;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);
            }
        }
        public void LayerRate_Set4_A2_Item_WaterRate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer rate - set 4.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 21780.34;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                string sName = "Layer 1";

                double Actual = Math.Round(WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Item(sName).AddRef().WaterRate, 2);

                double Expected = 5445.08;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void LayerRate_Set2_A2_GetAt_GasRate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 37100;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                int i = 0;

                double Actual = Math.Round(WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().GetAt(i).AddRef().GasRate, 2);

                double Expected = 13.91;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_Cond_AoF()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\Cond-2Layers.wflx");
                WFInt.OpenFile(sfile1);

                WFInt.WellModel.AddRef().Layers.AddRef().SetLayerStatus(1, true);
                double ActualAoF = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().AOF;
                double ExpectedAoF = 4.846700668;
                Assert.IsTrue(!Double.IsNaN(ActualAoF), "Failed to calculate AoF of Layer 1");
                Assert.AreEqual(ExpectedAoF, ActualAoF, 1E-5);

                ActualAoF = WFInt.WellModel.AddRef().Layers.AddRef().Item(2).AddRef().AOF;
                ExpectedAoF = 1.183389544;
                Assert.IsTrue(!Double.IsNaN(ActualAoF), "Failed to calculate AoF of Layer 2");
                Assert.AreEqual(ExpectedAoF, ActualAoF, 1E-5);

                WFInt.EndWellFlo();
            }
        }
        public void LayerRate_Set2_A3_Item_OilRate()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\get-one layer.wflx");

                WFInt.OpenFile(sfile);

                double dRate = 37100;

                WFInt.GetLayerRateCalculator().AddRef().Calculate(dRate);

                string sName = "Layer 1";

                double Actual = Math.Round(WFInt.GetLayerRateCalculator().AddRef().LayerRates.AddRef().Item(sName).AddRef().OilRate, 0);

                double Expected = 27825.0;

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }
        public void Layer_A1B_2_WellOrientation_Input()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\horizontal.wflx");
                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\horizontal_Output.wflx");

                WFInt.OpenFile(sfile);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WellOrientation = 0;

                short Actual = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WellOrientation;

                short Expected = 0;

                WFInt.SaveFile(sfile1);

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual);
            }
        }
        public void Layer_A2_WaterCut()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile1 = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\layer.wflx");

                WFInt.OpenFile(sfile1);

                double Actual = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterCut, 1);

                double Expected1 = 0.30;
                double Expected = Math.Round(Expected1, 1);

                WFInt.EndWellFlo();
                Assert.AreEqual(Expected, Actual, DeltaFraction.Default(Expected));
            }
        }