static void Main(string[] args)
        {
            try
            {
                if (args.Length == 0)
                {
                    Console.WriteLine("Uage :  CheckObjectType.exe <full file path > <val1> <val2> ");
                    return;
                }
                WFloInterface WfInt = new WFloInterface();
                WfInt.OpenFile(args[0]);
                var OpPtCalc = WfInt.GetOpPtCalculator();
                OpPtCalc.UsePCPPumpPerformanceRange = true;
                OpPtCalc.AutoSearchOpPtforPCP = false;
                var res = OpPtCalc.CalculateOperatingSpeedforPCP(Convert.ToDouble(args[1]), Convert.ToDouble(args[2]));
                Console.WriteLine(" Min Value " + OpPtCalc.MinimumRangeValue);
                Console.WriteLine(" Min Value " + OpPtCalc.MaximumRangeValue);
           
            }
            catch (Exception ex)
            {
                Console.WriteLine("Got Exception : "+ex.Message);
            }

        }
        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 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 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_A1_SetViscosityModelingData()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\PCP-ViscosityModeling.wflx");
                string OutPutfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\Saved layer.wflx");

                WFInt.OpenFile(sfile);

                Array psaTemperatureOld = Array.CreateInstance(typeof(double), 20);
                Array psaViscosityOld = Array.CreateInstance(typeof(double), 20);
                short ActualNo = 0;

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetViscosityModelingData(ref ActualNo, ref psaTemperatureOld, ref psaViscosityOld);

                psaTemperatureOld.SetValue(90, 2);
                psaViscosityOld.SetValue(13, 2);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().SetViscosityModelingData(3, psaTemperatureOld, psaViscosityOld);
                WFInt.SaveFile(OutPutfile);

                Array psaTemperatureNew = Array.CreateInstance(typeof(double), 20);
                Array psaViscosityNew = Array.CreateInstance(typeof(double), 20);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();

                WFIntSaved.OpenFile(OutPutfile);

                WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetViscosityModelingData(ref ActualNo, ref psaTemperatureNew, ref psaViscosityNew);

                double TempratureAt0 = (double)psaTemperatureNew.GetValue(0);
                double TempratureAt1 = (double)psaTemperatureNew.GetValue(1);
                double TempratureAt2 = (double)psaTemperatureNew.GetValue(2);

                double ViscosityAt0 = (double)psaViscosityNew.GetValue(0);
                double ViscosityAt1 = (double)psaViscosityNew.GetValue(1);
                double ViscosityAt2 = (double)psaViscosityNew.GetValue(2);

                Assert.AreEqual(80, TempratureAt0, DeltaFraction.Default(80));
                Assert.AreEqual(85, TempratureAt1, DeltaFraction.Default(85));
                Assert.AreEqual(90, TempratureAt2, DeltaFraction.Default(90));
                Assert.AreEqual(17, ViscosityAt0, DeltaFraction.Default(17));
                Assert.AreEqual(15, ViscosityAt1, DeltaFraction.Default(15));
                Assert.AreEqual(13, ViscosityAt2, DeltaFraction.Default(13));
            }
        }
        public void LayerCollection_LayerStatus()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

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

                WFInt.OpenFile(sfile);

                LayerCollection pLayerCollection = new LayerCollection();
                pLayerCollection.AddRef();

                WFInt.WellModel.AddRef().GetLayerCollectionData(pLayerCollection);

                pLayerCollection.SetLayerStatus(2, true);
                pLayerCollection.SetLayerStatus(1, true);

                WFInt.WellModel.AddRef().SetLayerCollectionData(pLayerCollection);

                WFInt.SaveFile(sfileOutPut);

                WFloInterface WFInt1 = new WFloInterface();
                WFInt1.AddRef();
                WFInt1.OpenFile(sfileOutPut);

                LayerCollection pLayerCollection1 = new LayerCollection();
                pLayerCollection1.AddRef();

                WFInt1.WellModel.AddRef().GetLayerCollectionData(pLayerCollection1);

                bool ActualStatus1 = pLayerCollection1.GetLayerStatus(1);
                string ActualName1 = pLayerCollection1.GetLayerName(1);
                bool ActualStatus2 = pLayerCollection1.GetLayerStatus(2);
                string ActualName2 = pLayerCollection1.GetLayerName(2);

                Assert.AreEqual(true, ActualStatus1);
                Assert.AreEqual("Layer 1", ActualName1);
                Assert.AreEqual(true, ActualStatus2);
                Assert.AreEqual("New Layer *1", ActualName2);
            }
        }
        public void Layer_A1_CalculateProductivityIndex()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\PCP-ViscosityModeling.wflx");

                WFInt.OpenFile(sfile);
                double dIndex = 0;

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().CalculateProductivityIndex(400, 400, ref dIndex);

                double ActualIndex = Math.Round(dIndex, 4);
                Assert.AreEqual(0.3075, ActualIndex, DeltaFraction.Default(0.3077));
            }
        }
        public void MultiStageData_RemoveOneStage()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/layers active.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved layers active.wflx");

                WFInt.OpenFile(sfile);

                int initialCount = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                Assert.AreEqual(initialCount, 0);

                MultiFractureData firstStage = new MultiFractureData();

                firstStage.StageLength = 300;
                firstStage.TopMD = 10000;

                FractureData firstFracture = new FractureData();
                firstFracture.AddRef();

                firstFracture.bUseFracFaceSkin = true;
                firstFracture.bUseCalcdFracDmgSkin = true;
                firstFracture.bUseFracChokedSkin = true;
                firstFracture.bUseCalcdFracChokedSkin = true;
                firstFracture.bUseCalcdSkin = true;
                firstFracture.FracSkin = 0.5;
                firstFracture.FracHalfSpacing = 200;
                firstFracture.FracWidth = 5;
                firstFracture.FracHalfLength = 250;
                firstFracture.FracHeight = 2;
                firstFracture.FracPermNearWB = 0.2;
                firstFracture.FracWidthNearWB = 0.25;
                firstFracture.FracPerm = 0.5;
                firstFracture.FracDmgPerm = 0.74;
                firstFracture.FracDmgThick = 52;
                firstFracture.FracDmgSkinCalcd = 0.6;
                firstFracture.FracDmgSkinMeas = 75;
                firstFracture.FracChokedHalfLength = 300;
                firstFracture.FracChokedSkinCalcd = 0.65;
                firstFracture.FracChokedSkinMeas = 95;
                firstFracture.DarcySkinCalcd = 0.7;
                firstFracture.DarcySkinManual = 0.15;

                firstStage.AddRef().AddFractureData(firstFracture);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().AddMultiFractureData(firstStage);

                int afterAddingCount = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                //  int afterAddingCount = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().;

                Assert.AreEqual(afterAddingCount, 1);

                #region read the number of fractures from the WellTech
                MultiFractureData savedMultiFracture = new MultiFractureData();
                savedMultiFracture.AddRef();

                FractureData savedFirstFracture = new FractureData();
                savedFirstFracture.AddRef();

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 0, savedFirstFracture);

                double Stagelength_1 = savedMultiFracture.StageLength;
                double TopMD_1 = savedMultiFracture.TopMD;

                int CountFractures = savedMultiFracture.NumberOfFractures;

                Assert.AreEqual(CountFractures, 1);

                Assert.AreEqual(300, savedMultiFracture.StageLength, DeltaFraction.Default(300));
                Assert.AreEqual(10000, savedMultiFracture.TopMD, DeltaFraction.Default(10000));

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().RemoveAllOneStageData();

                int afterRemoveAll = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                Assert.AreEqual(afterRemoveAll, 0);

                #endregion
            }
        }
        public void MultiStageData_MultiFractureProductivities()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Multiple Fractures.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved Multiple Fractures.wflx");

                //open wellflo
                WFInt.OpenFile(sfile);

                int initialCount = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;
                bool bMatrix = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseReservoirMatrixCorrection;

                double ReservoirPI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ReservoirProductivityIndex;
                double FracturePI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().FractureProductivityIndex;
                double WellborePI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WellboreProductivityIndex;
                double MatrixPI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().MatrixProductivityIndex;

                double PI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ProductivityIndex;

                ReservoirPI = Math.Round(ReservoirPI, 4);
                FracturePI = Math.Round(FracturePI, 4);
                WellborePI = Math.Round(WellborePI, 4);
                MatrixPI = Math.Round(MatrixPI, 1);
                PI = Math.Round(PI, 4);

                Assert.AreEqual(ReservoirPI, 1.0072, DeltaFraction.Default(ReservoirPI));
                Assert.AreEqual(FracturePI, 0.4215, DeltaFraction.Default(FracturePI));
                Assert.AreEqual(WellborePI, 0.0354, DeltaFraction.Default(WellborePI));
                Assert.AreEqual(MatrixPI, 0.0, DeltaFraction.Default(MatrixPI));
                Assert.AreEqual(PI, 0.0317, DeltaFraction.Default(PI));

                // Get the first stage first fracture pro
                MultiFractureData savedMultiFracture = new MultiFractureData();
                savedMultiFracture.AddRef();
                FractureData savedFirstFracture = new FractureData();
                savedFirstFracture.AddRef();
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 0, savedFirstFracture);

                double Stagelength_1 = savedMultiFracture.StageLength;
                double TopMD_1 = savedMultiFracture.TopMD;
                int CountFractures = savedMultiFracture.NumberOfFractures;

                Assert.AreEqual(CountFractures, 1);
                Assert.AreEqual(313, Stagelength_1, DeltaFraction.Default(313));
                Assert.AreEqual(5000, TopMD_1, DeltaFraction.Default(5000));

                // Use the Reservoir Matrix Correction
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseReservoirMatrixCorrection = true; //true
                bool bMatrix_1 = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseReservoirMatrixCorrection;
                //save wellflo
                WFInt.SaveFile(sSavedfile);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();
                //open the saved wellflo
                WFIntSaved.OpenFile(sSavedfile);

                bool savedbMatrix = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseReservoirMatrixCorrection;
                Assert.AreEqual(savedbMatrix, true);

                double NewReservoirPI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ReservoirProductivityIndex;
                double NewFracturePI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().FractureProductivityIndex;
                double NewWellborePI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WellboreProductivityIndex;
                double NewMatrixPI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().MatrixProductivityIndex;

                double NewPI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ProductivityIndex;

                NewReservoirPI = Math.Round(NewReservoirPI, 4);
                NewFracturePI = Math.Round(NewFracturePI, 4);
                NewWellborePI = Math.Round(NewWellborePI, 4);
                NewMatrixPI = Math.Round(NewMatrixPI, 4);
                NewPI = Math.Round(NewPI, 4);

                Assert.AreEqual(NewReservoirPI, 1.0072, DeltaFraction.Default(NewReservoirPI));
                Assert.AreEqual(NewFracturePI, 0.4215, DeltaFraction.Default(NewFracturePI));
                Assert.AreEqual(NewWellborePI, 0.0354, DeltaFraction.Default(NewWellborePI));
                Assert.AreEqual(NewMatrixPI, 0.0122, DeltaFraction.Default(NewMatrixPI));
                Assert.AreEqual(NewPI, 0.0439, DeltaFraction.Default(NewPI));

            }
        }
        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_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 Layer_Put_LayerParameters_Vogel()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

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

                WFInt.OpenFile(sfile);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterCut = 0.3;
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().VogelPCoefficient = 0.25;

                WFInt.SaveFile(OutPutfile);

                WFloInterface WFInt1 = new WFloInterface();
                WFInt1.AddRef();

                WFInt1.OpenFile(OutPutfile);

                double ActualWaterCut = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterCut;
                double ActualVogelPCoefficient = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().VogelPCoefficient;
                double ActualProductivityIndex = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ProductivityIndex;
                double ActualAOF = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().AOF;

                double ExpectedWaterCut = 0.3;
                double ExpectedVogelPCoefficient = 0.25;
                double ExpectedProductivityIndex = 7.8599;
                double ExpectedAOF = 37637.9218;

                Assert.AreEqual(ExpectedWaterCut, ActualWaterCut, DeltaFraction.Default(ExpectedWaterCut));
                Assert.AreEqual(ExpectedVogelPCoefficient, ActualVogelPCoefficient, DeltaFraction.Default(ExpectedVogelPCoefficient));
                Assert.AreEqual(ExpectedProductivityIndex, ActualProductivityIndex, DeltaFraction.Default(ExpectedProductivityIndex));
                Assert.AreEqual(ExpectedAOF, ActualAOF, DeltaFraction.Default(ExpectedAOF));
            }
        }
        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 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 MultiStageData_ChokedModel()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/layers active.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved layers active.wflx");

                WFInt.OpenFile(sfile);

                MultiFractureData firstStage = new MultiFractureData();

                firstStage.StageLength = 300;
                firstStage.TopMD = 10000;
                firstStage.ChokedModel = 1;

                FractureData firstFracture = new FractureData();
                firstFracture.AddRef();

                firstFracture.bUseFracFaceSkin = true;
                firstFracture.bUseCalcdFracDmgSkin = true;
                firstFracture.bUseFracChokedSkin = true;
                firstFracture.bUseCalcdFracChokedSkin = true;
                firstFracture.bUseCalcdSkin = true;
                firstFracture.FracSkin = 0.5;
                firstFracture.FracHalfSpacing = 200;
                firstFracture.FracWidth = 5;
                firstFracture.FracHalfLength = 250;
                firstFracture.FracHeight = 2;
                firstFracture.FracPermNearWB = 0.2;
                firstFracture.FracWidthNearWB = 0.25;
                firstFracture.FracPerm = 0.5;
                firstFracture.FracDmgPerm = 0.74;
                firstFracture.FracDmgThick = 52;
                firstFracture.FracDmgSkinCalcd = 0.6;
                firstFracture.FracDmgSkinMeas = 75;
                firstFracture.FracChokedHalfLength = 300;
                firstFracture.FracChokedSkinCalcd = 0.65;
                firstFracture.FracChokedSkinMeas = 95;
                firstFracture.DarcySkinCalcd = 0.7;
                firstFracture.DarcySkinManual = 0.15;

                firstStage.AddRef().AddFractureData(firstFracture);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().AddMultiFractureData(firstStage);

                WFInt.SaveFile(sSavedfile);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();

                WFIntSaved.OpenFile(sSavedfile);

                MultiFractureData savedMultiFracture = new MultiFractureData();
                savedMultiFracture.AddRef();

                FractureData savedFracture = new FractureData();
                savedFracture.AddRef();

                WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 0, savedFracture);

                short ChokedModel = savedMultiFracture.ChokedModel;

                Assert.AreEqual(1, ChokedModel);
            }
        }
        public void MultiStageData_GetOneStage()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/layers active.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved layers active.wflx");

                WFInt.OpenFile(sfile);

                int initialCount = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                Assert.AreEqual(initialCount, 0);

                MultiFractureData firstStage = new MultiFractureData();

                firstStage.StageLength = 300;
                firstStage.TopMD = 10000;

                FractureData firstFracture = new FractureData();
                firstFracture.AddRef();

                firstFracture.bUseFracFaceSkin = true;
                firstFracture.bUseCalcdFracDmgSkin = true;
                firstFracture.bUseFracChokedSkin = true;
                firstFracture.bUseCalcdFracChokedSkin = true;
                firstFracture.bUseCalcdSkin = true;
                firstFracture.FracSkin = 0.5;
                firstFracture.FracHalfSpacing = 200;
                firstFracture.FracWidth = 5;
                firstFracture.FracHalfLength = 250;
                firstFracture.FracHeight = 2;
                firstFracture.FracPermNearWB = 0.2;
                firstFracture.FracWidthNearWB = 0.25;
                firstFracture.FracPerm = 0.5;
                firstFracture.FracDmgPerm = 0.74;
                firstFracture.FracDmgThick = 52;
                firstFracture.FracDmgSkinCalcd = 0.6;
                firstFracture.FracDmgSkinMeas = 75;
                firstFracture.FracChokedHalfLength = 300;
                firstFracture.FracChokedSkinCalcd = 0.65;
                firstFracture.FracChokedSkinMeas = 95;
                firstFracture.DarcySkinCalcd = 0.7;
                firstFracture.DarcySkinManual = 0.15;

                firstStage.AddRef().AddFractureData(firstFracture);

                FractureData secondFracture = new FractureData();
                secondFracture.AddRef();

                secondFracture.bUseFracFaceSkin = true;
                secondFracture.bUseCalcdFracDmgSkin = true;
                secondFracture.bUseFracChokedSkin = true;
                secondFracture.bUseCalcdFracChokedSkin = true;
                secondFracture.bUseCalcdSkin = true;
                secondFracture.FracSkin = 0.345;
                secondFracture.FracHalfSpacing = 234;
                secondFracture.FracWidth = 0.5;
                secondFracture.FracHalfLength = 350;
                secondFracture.FracHeight = 2;
                secondFracture.FracPermNearWB = 0.2;
                secondFracture.FracWidthNearWB = 0.25;
                secondFracture.FracPerm = 0.5;
                secondFracture.FracDmgPerm = 0.74;
                secondFracture.FracDmgThick = 52;
                secondFracture.FracDmgSkinCalcd = 0.6;
                secondFracture.FracDmgSkinMeas = 75;
                secondFracture.FracChokedHalfLength = 300;
                secondFracture.FracChokedSkinCalcd = 0.65;
                secondFracture.FracChokedSkinMeas = 95;
                secondFracture.DarcySkinCalcd = 0.7;
                secondFracture.DarcySkinManual = 0.15;

                firstStage.AddRef().AddFractureData(secondFracture);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().AddMultiFractureData(firstStage);

                WFInt.SaveFile(sSavedfile);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();

                WFIntSaved.OpenFile(sSavedfile);

                int afterAddingCount = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                //  int afterAddingCount = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().;

                Assert.AreEqual(afterAddingCount, 1);

                #region read the number of fractures from the WellTech
                MultiFractureData savedMultiFracture = new MultiFractureData();
                savedMultiFracture.AddRef();

                FractureData savedFirstFracture = new FractureData();
                savedFirstFracture.AddRef();

                WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 0, savedFirstFracture);

                double Stagelength_1 = savedMultiFracture.StageLength;
                double TopMD_1 = savedMultiFracture.TopMD;

                int CountFractures = savedMultiFracture.NumberOfFractures;

                Assert.AreEqual(CountFractures, 2);

                Assert.AreEqual(300, savedMultiFracture.StageLength, DeltaFraction.Default(300));
                Assert.AreEqual(10000, savedMultiFracture.TopMD, DeltaFraction.Default(0.5));
                #endregion

                # region get firstfracture properties

                Assert.AreEqual(0.5, savedFirstFracture.FracSkin, DeltaFraction.Default(0.5));
                Assert.AreEqual(200, savedFirstFracture.FracHalfSpacing, DeltaFraction.Default(200));
                Assert.AreEqual(5, savedFirstFracture.FracWidth, DeltaFraction.Default(5));
                Assert.AreEqual(250, savedFirstFracture.FracHalfLength, DeltaFraction.Default(250));
                Assert.AreEqual(2, savedFirstFracture.FracHeight, DeltaFraction.Default(2));
                Assert.AreEqual(0.2, savedFirstFracture.FracPermNearWB, DeltaFraction.Default(0.2));
                Assert.AreEqual(0.25, savedFirstFracture.FracWidthNearWB, DeltaFraction.Default(0.25));
                Assert.AreEqual(0.5, savedFirstFracture.FracPerm, DeltaFraction.Default(0.5));
                Assert.AreEqual(0.74, savedFirstFracture.FracDmgPerm, DeltaFraction.Default(0.74));
                Assert.AreEqual(52, savedFirstFracture.FracDmgThick, DeltaFraction.Default(52));
                Assert.AreEqual(0.6, savedFirstFracture.FracDmgSkinCalcd, DeltaFraction.Default(0.6));
                Assert.AreEqual(75, savedFirstFracture.FracDmgSkinMeas, DeltaFraction.Default(75));
                Assert.AreEqual(300, savedFirstFracture.FracChokedHalfLength, DeltaFraction.Default(300));

                Assert.AreEqual(0.65, savedFirstFracture.FracChokedSkinCalcd, DeltaFraction.Default(0.65));
                Assert.AreEqual(95, savedFirstFracture.FracChokedSkinMeas, DeltaFraction.Default(95));

                Assert.AreEqual(0.7, savedFirstFracture.DarcySkinCalcd, DeltaFraction.Default(0.7));
                Assert.AreEqual(0.15, savedFirstFracture.DarcySkinManual, DeltaFraction.Default(0.15));

                #endregion

                #region get secondfracture properties
                WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 1, savedFirstFracture);

                // WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture);

                // Fractures are added to the stage before writing to the WellTech. Both stage and fracture properties will be gotten from the WellTech when calling the GetMultiFractureData,
                // then fracture properties will be read based on the Stage class. Thus, no GetFractureData method is used here.

                Assert.AreEqual(0.345, savedFirstFracture.FracSkin, DeltaFraction.Default(0.345));
                Assert.AreEqual(234, savedFirstFracture.FracHalfSpacing, DeltaFraction.Default(234));
                Assert.AreEqual(0.5, savedFirstFracture.FracWidth, DeltaFraction.Default(0.5));
                Assert.AreEqual(350, savedFirstFracture.FracHalfLength, DeltaFraction.Default(350));
                Assert.AreEqual(2, savedFirstFracture.FracHeight, DeltaFraction.Default(2));
                Assert.AreEqual(0.2, savedFirstFracture.FracPermNearWB, DeltaFraction.Default(0.2));
                Assert.AreEqual(0.25, savedFirstFracture.FracWidthNearWB, DeltaFraction.Default(0.25));
                Assert.AreEqual(0.5, savedFirstFracture.FracPerm, DeltaFraction.Default(0.5));
                Assert.AreEqual(0.74, savedFirstFracture.FracDmgPerm, DeltaFraction.Default(0.74));
                Assert.AreEqual(52, savedFirstFracture.FracDmgThick, DeltaFraction.Default(52));
                Assert.AreEqual(0.6, savedFirstFracture.FracDmgSkinCalcd, DeltaFraction.Default(0.6));
                Assert.AreEqual(75, savedFirstFracture.FracDmgSkinMeas, DeltaFraction.Default(75));
                Assert.AreEqual(300, savedFirstFracture.FracChokedHalfLength, DeltaFraction.Default(300));

                Assert.AreEqual(0.65, savedFirstFracture.FracChokedSkinCalcd, DeltaFraction.Default(0.65));
                Assert.AreEqual(95, savedFirstFracture.FracChokedSkinMeas, DeltaFraction.Default(95));

                Assert.AreEqual(0.7, savedFirstFracture.DarcySkinCalcd, DeltaFraction.Default(0.7));
                Assert.AreEqual(0.15, savedFirstFracture.DarcySkinManual, DeltaFraction.Default(0.15));
                #endregion
            }
        }
        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 Layer_Put_TestData_Vogel()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

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

                WFInt.OpenFile(sfile);
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().IPREntryModel = 1; //1 - Test Entry Model
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterCut = 0.3;
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().VogelPCoefficient = 0.25;
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().SetTestPoint1Data(5000, 1250);

                WFInt.SaveFile(OutPutfile);

                WFloInterface WFInt1 = new WFloInterface();
                WFInt1.AddRef();

                WFInt1.OpenFile(OutPutfile);

                double ActualWaterCut = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterCut;
                double ActualVogelPCoefficient = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().VogelPCoefficient;
                double ActualProductivityIndex = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ProductivityIndex;
                double ActualAOF = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().AOF;

                double ExpectedWaterCut = 0.3;
                double ExpectedVogelPCoefficient = 0.25;
                double ExpectedProductivityIndex = 1.2500;
                double ExpectedAOF = 5985.7;

                Assert.AreEqual(ExpectedWaterCut, ActualWaterCut, DeltaFraction.Default(ExpectedWaterCut));
                Assert.AreEqual(ExpectedVogelPCoefficient, ActualVogelPCoefficient, DeltaFraction.Default(ExpectedVogelPCoefficient));
                Assert.AreEqual(ExpectedProductivityIndex, ActualProductivityIndex, DeltaFraction.Default(ExpectedProductivityIndex));
                Assert.AreEqual(ExpectedAOF, ActualAOF, DeltaFraction.Default(ExpectedAOF));
            }
        }
        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 MultiStageData_SetOneStage()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/layers active.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved layers active.wflx");

                WFInt.OpenFile(sfile);

                int initialCount = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                Assert.AreEqual(initialCount, 0);

                MultiFractureData firstStage = new MultiFractureData();

                firstStage.StageLength = 300;
                firstStage.TopMD = 10000;

                FractureData firstFracture = new FractureData();
                firstFracture.AddRef();

                firstFracture.bUseFracFaceSkin = true;
                firstFracture.bUseCalcdFracDmgSkin = true;
                firstFracture.bUseFracChokedSkin = true;
                firstFracture.bUseCalcdFracChokedSkin = true;
                firstFracture.bUseCalcdSkin = true;
                firstFracture.FracSkin = 0.5;
                firstFracture.FracHalfSpacing = 200;
                firstFracture.FracWidth = 5;
                firstFracture.FracHalfLength = 250;
                firstFracture.FracHeight = 2;
                firstFracture.FracPermNearWB = 0.2;
                firstFracture.FracWidthNearWB = 0.25;
                firstFracture.FracPerm = 0.5;
                firstFracture.FracDmgPerm = 0.74;
                firstFracture.FracDmgThick = 52;
                firstFracture.FracDmgSkinCalcd = 0.6;
                firstFracture.FracDmgSkinMeas = 75;
                firstFracture.FracChokedHalfLength = 300;
                firstFracture.FracChokedSkinCalcd = 0.65;
                firstFracture.FracChokedSkinMeas = 95;
                firstFracture.DarcySkinCalcd = 0.7;
                firstFracture.DarcySkinManual = 0.15;

                firstStage.AddRef().AddFractureData(firstFracture);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().AddMultiFractureData(firstStage);

                firstStage.StageLength = 400;
                firstStage.TopMD = 12345;

                firstFracture.FracSkin = 1.8;
                firstFracture.FracHalfSpacing = 100;

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().SetMultiFractureData(0, firstStage, 0, firstFracture);

                WFInt.SaveFile(sSavedfile);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();

                WFIntSaved.OpenFile(sSavedfile);

                int afterAddingCount = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().NumberOfFractureStages;

                //  int afterAddingCount = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().;

                Assert.AreEqual(afterAddingCount, 1);

                #region read the number of fractures from the WellTech
                MultiFractureData savedMultiFracture = new MultiFractureData();
                savedMultiFracture.AddRef();

                FractureData savedFirstFracture = new FractureData();
                savedFirstFracture.AddRef();

                WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GetMultiStageData().AddRef().GetMultiFractureData(0, savedMultiFracture, 0, savedFirstFracture);

                double Stagelength_1 = savedMultiFracture.StageLength;
                double TopMD_1 = savedMultiFracture.TopMD;

                int CountFractures = savedMultiFracture.NumberOfFractures;

                Assert.AreEqual(CountFractures, 1);

                Assert.AreEqual(400, savedMultiFracture.StageLength, DeltaFraction.Default(400));
                Assert.AreEqual(12345, savedMultiFracture.TopMD, DeltaFraction.Default(12345));
                #endregion

                # region get firstfracture properties

                Assert.AreEqual(1.8, savedFirstFracture.FracSkin, DeltaFraction.Default(1.8));       // Value has been changed.
                Assert.AreEqual(100, savedFirstFracture.FracHalfSpacing, DeltaFraction.Default(100)); // Value has been changed.
                Assert.AreEqual(5, savedFirstFracture.FracWidth, DeltaFraction.Default(5));
                Assert.AreEqual(250, savedFirstFracture.FracHalfLength, DeltaFraction.Default(250));
                Assert.AreEqual(2, savedFirstFracture.FracHeight, DeltaFraction.Default(2));
                Assert.AreEqual(0.2, savedFirstFracture.FracPermNearWB, DeltaFraction.Default(0.2));
                Assert.AreEqual(0.25, savedFirstFracture.FracWidthNearWB, DeltaFraction.Default(0.25));
                Assert.AreEqual(0.5, savedFirstFracture.FracPerm, DeltaFraction.Default(0.5));
                Assert.AreEqual(0.74, savedFirstFracture.FracDmgPerm, DeltaFraction.Default(0.74));
                Assert.AreEqual(52, savedFirstFracture.FracDmgThick, DeltaFraction.Default(52));
                Assert.AreEqual(0.6, savedFirstFracture.FracDmgSkinCalcd, DeltaFraction.Default(0.6));
                Assert.AreEqual(75, savedFirstFracture.FracDmgSkinMeas, DeltaFraction.Default(75));
                Assert.AreEqual(300, savedFirstFracture.FracChokedHalfLength, DeltaFraction.Default(300));

                Assert.AreEqual(0.65, savedFirstFracture.FracChokedSkinCalcd, DeltaFraction.Default(0.65));
                Assert.AreEqual(95, savedFirstFracture.FracChokedSkinMeas, DeltaFraction.Default(95));

                Assert.AreEqual(0.7, savedFirstFracture.DarcySkinCalcd, DeltaFraction.Default(0.7));
                Assert.AreEqual(0.15, savedFirstFracture.DarcySkinManual, DeltaFraction.Default(0.15));
                #endregion

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

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

                WFInt.OpenFile(sfile);

                // without the fix WPS will crash while executing the below line
                string ActualName = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Name;
            }
        }
        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_Put_Manual_Fetkovich()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/BlackOil_Manual_Fetkovich.wflx");

                WFInt.OpenFile(sfile);

                double PI = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().ProductivityIndex;
                Assert.AreEqual(6000, PI, DeltaFraction.Default(6000));
            }
        }
        public void Layer_A1_CGR()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

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

                WFInt.OpenFile(sfile);

                double ActualCGR = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().CGR;
                double ActualCO2MolePct = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().CO2MolePct;
                double ActualDarcySkin = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().DarcySkin;
                double ActualDietzFactor = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().DietzFactor, 2);
                double ActualDrainageArea = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().DrainageArea;
                double ActualGasGravity = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().GasGravity, 1);
                double ActualH2SMolePct = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().H2SMolePct;
                double ActualHorizontalPermeability = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().HorizontalPermeability;
                double ActualIPREntryModel = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().IPREntryModel;
                double ActualIPRModel = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().IPRModel;
                double ActualMD = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().MeasuredDepth;
                double ActualN2MolePct = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().N2MolePct;
                double ActualNonDarcySkin = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().NonDarcySkin;
                double ActualOilGravity = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().OilGravity, 3);
                double ActualPressure = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Pressure;
                double ActualSalinity = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Salinity;
                double ActualTemperature = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Temperature;
                double ActualThickness = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Thickness;
                double ActualTrueVerticalDepth = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().TrueVerticalDepth, 2);
                double ActualVerticalPermeability = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().VerticalPermeability, 0);
                double ActualWaterGravity = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WaterGravity, 4);
                double ActualWellBoreRadius = Math.Round(WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WellBoreRadius, 1);
                double ActualWGR = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().WGR;
                bool ActualNonDarcyModel = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().NonDarcyModel;
                int ActualSaturationModel = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().SaturationModel;
                short ActualNumber = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Number;
                string ActualName = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().Name;

                double ExpectedCGR = 150;
                double ExpectedCO2MolePct = 0;
                double ExpectedDarcySkin = 1;
                double ExpectedDietzFactor = 31.62;
                double ExpectedDrainageArea = 27878006;
                double ExpectedGasGravity = 0.7;
                double ExpectedH2SMolePct = 0;
                double ExpectedHorizontalPermeability = 200;
                double ExpectedIPREntryModel = 0;
                double ExpectedIPRModel = 3;
                double ExpectedMD = 14680;
                double ExpectedN2MolePct = 0;
                double ExpectedNonDarcySkin = 0;
                double ExpectedOilGravity = 0.785;
                double ExpectedPressure = 8050;
                double ExpectedSalinity = 30000;
                double ExpectedTemperature = 230;
                double ExpectedThickness = 100;
                double ExpectedTrueVerticalDepth = 13299.66;
                double ExpectedVerticalPermeability = 200;
                double ExpectedWaterGravity = 1.0198;
                double ExpectedWellBoreRadius = 0.4;
                double ExpectedWGR = 150;
                bool ExpectedNonDarcyModel = true;
                int ExpectedSaturationModel = 0;
                short ExpectedNumber = 1;
                string ExpectedName = "Layer 1";

                Assert.AreEqual(ExpectedCGR, ActualCGR, DeltaFraction.Default(ExpectedCGR));
                Assert.AreEqual(ExpectedCO2MolePct, ActualCO2MolePct, DeltaFraction.Default(ExpectedCO2MolePct));
                Assert.AreEqual(ExpectedDarcySkin, ActualDarcySkin, DeltaFraction.Default(ExpectedDarcySkin));
                Assert.AreEqual(ExpectedDietzFactor, ActualDietzFactor, DeltaFraction.Default(ExpectedDietzFactor));
                Assert.AreEqual(ExpectedDrainageArea, ActualDrainageArea, DeltaFraction.Default(ExpectedDrainageArea));
                Assert.AreEqual(ExpectedGasGravity, ActualGasGravity, DeltaFraction.Default(ExpectedGasGravity));
                Assert.AreEqual(ExpectedH2SMolePct, ActualH2SMolePct, DeltaFraction.Default(ExpectedH2SMolePct));
                Assert.AreEqual(ExpectedHorizontalPermeability, ActualHorizontalPermeability, DeltaFraction.Default(ExpectedHorizontalPermeability));
                Assert.AreEqual(ExpectedIPREntryModel, ActualIPREntryModel, DeltaFraction.Default(ExpectedIPREntryModel));
                Assert.AreEqual(ExpectedIPRModel, ActualIPRModel, DeltaFraction.Default(ExpectedIPRModel));
                Assert.AreEqual(ExpectedMD, ActualMD, DeltaFraction.Default(ExpectedMD));
                Assert.AreEqual(ExpectedN2MolePct, ActualN2MolePct, DeltaFraction.Default(ExpectedN2MolePct));
                Assert.AreEqual(ExpectedNonDarcySkin, ActualNonDarcySkin, DeltaFraction.Default(ExpectedNonDarcySkin));
                Assert.AreEqual(ExpectedOilGravity, ActualOilGravity, DeltaFraction.Default(ExpectedOilGravity));
                Assert.AreEqual(ExpectedPressure, ActualPressure, DeltaFraction.Default(ExpectedPressure));
                Assert.AreEqual(ExpectedSalinity, ActualSalinity, DeltaFraction.Default(ExpectedSalinity));
                Assert.AreEqual(ExpectedTemperature, ActualTemperature, DeltaFraction.Default(ExpectedTemperature));
                Assert.AreEqual(ExpectedThickness, ActualThickness, DeltaFraction.Default(ExpectedThickness));
                Assert.AreEqual(ExpectedTrueVerticalDepth, ActualTrueVerticalDepth, DeltaFraction.Default(ExpectedTrueVerticalDepth));
                Assert.AreEqual(ExpectedVerticalPermeability, ActualVerticalPermeability, DeltaFraction.Default(ExpectedVerticalPermeability));
                Assert.AreEqual(ExpectedWaterGravity, ActualWaterGravity, DeltaFraction.Default(ExpectedWaterGravity));
                Assert.AreEqual(ExpectedWellBoreRadius, ActualWellBoreRadius, DeltaFraction.Default(ExpectedWellBoreRadius));
                Assert.AreEqual(ExpectedWGR, ActualWGR, DeltaFraction.Default(ExpectedWGR));
                Assert.AreEqual(ExpectedNonDarcyModel, ActualNonDarcyModel);
                Assert.AreEqual(ExpectedSaturationModel, ActualSaturationModel);
                Assert.AreEqual(ExpectedNumber, ActualNumber);
                Assert.AreEqual(ExpectedName, ActualName);
            }
        }
        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 Layer_A1_MultiLayer_Both_Active()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_ReoForecast\\before active layer.wflx");

                WFInt.OpenFile(sfile);

                bool firstLayer = WFInt.WellModel.AddRef().Layers.AddRef().GetLayerStatus(1);

                bool secondLayer = WFInt.WellModel.AddRef().Layers.AddRef().GetLayerStatus(2);

                Assert.AreEqual(false, firstLayer);
                Assert.AreEqual(true, secondLayer);

                //make both layer active
                WFInt.WellModel.AddRef().Layers.AddRef().SetLayerStatus(1, true);

                WFInt.AddRef().GetOpPtCalculator().AddRef().CalculateOperatingPoint(50, 0);

                double LiqRateAfterSet = WFInt.GetOpPtCalculator().AddRef().OilRate + WFInt.GetOpPtCalculator().AddRef().WaterRate;

                double PressureAfterSet = WFInt.GetOpPtCalculator().AddRef().OperatingPressure;

                Assert.AreEqual(4778.4, LiqRateAfterSet, DeltaFraction.Default(4778.4));
                Assert.AreEqual(3655.1, PressureAfterSet, DeltaFraction.Default(3655.1));

                bool firstLayerAfterChange = WFInt.WellModel.AddRef().Layers.AddRef().GetLayerStatus(1);
                bool secondLayerAfterChange = WFInt.WellModel.AddRef().Layers.AddRef().GetLayerStatus(2);

                Assert.AreEqual(true, firstLayerAfterChange);
                Assert.AreEqual(true, secondLayerAfterChange);

                // just making it unchanges beacuse many times changes in global variable causes a problem
                WFInt.WellModel.AddRef().Layers.AddRef().SetLayerStatus(2, true);
                WFInt.WellModel.AddRef().Layers.AddRef().SetLayerStatus(1, false);
            }
        }
        public void Layer_Put_PartingPressure()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\injection well.wflx");
                string OutPutfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer\\Saved injection well.wflx");

                WFInt.OpenFile(sfile);

                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().PartingPressure = 7100;

                WFInt.SaveFile(OutPutfile);

                WFloInterface WFInt1 = new WFloInterface();
                WFInt1.AddRef();

                WFInt1.OpenFile(OutPutfile);

                double ActualOilGravity = WFInt1.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().PartingPressure;

                double ExpectedPartingPressure = 7100;

                Assert.AreEqual(ExpectedPartingPressure, ActualOilGravity, DeltaFraction.Default(ExpectedPartingPressure));
            }
        }
        public void MultiStageData_CalculatedDietZFactor()
        {
            using (new LifeTimeScope())
            {
                WFloInterface WFInt = new WFloInterface();
                WFInt.AddRef();

                string sfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Multiple Fractures.wflx");
                string sSavedfile = WellFloFileLocation.BaselineWPSModel("WPS_Layer/Saved Multiple Fractures.wflx");

                //open wellflo
                WFInt.OpenFile(sfile);

                bool bMatrix = WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseCalcDietz;
                Assert.AreEqual(bMatrix, true);

                // Use the Reservoir Matrix Correction
                WFInt.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseCalcDietz = false;
                //save wellflo
                WFInt.SaveFile(sSavedfile);

                WFloInterface WFIntSaved = new WFloInterface();
                WFIntSaved.AddRef();
                //open the saved wellflo
                WFIntSaved.OpenFile(sSavedfile);

                bool savedbMatrix = WFIntSaved.WellModel.AddRef().Layers.AddRef().Item(1).AddRef().UseCalcDietz;
                Assert.AreEqual(savedbMatrix, false);

            }
        }
        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);
            }
        }