From 7d22cc5d9cf09c876c384d1d8414f9035da37fbd Mon Sep 17 00:00:00 2001
From: Wenqing Wang <wenqing.wang@ufz.de>
Date: Wed, 14 Dec 2016 10:54:30 +0100
Subject: [PATCH] [FLTest] Modified the test for FluidProperties

---
 Tests/MaterialLib/TestFluidProperties.cpp | 59 ++++++++++-------------
 1 file changed, 26 insertions(+), 33 deletions(-)

diff --git a/Tests/MaterialLib/TestFluidProperties.cpp b/Tests/MaterialLib/TestFluidProperties.cpp
index 260b0a6eac4..8369bb755bb 100644
--- a/Tests/MaterialLib/TestFluidProperties.cpp
+++ b/Tests/MaterialLib/TestFluidProperties.cpp
@@ -1,5 +1,5 @@
 /**
- *  \brief Test Composite density viscosity models
+ *  \brief Test the creator of FluidProperties
  *
  *  \copyright
  *   Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org)
@@ -13,56 +13,49 @@
 
 #include <gtest/gtest.h>
 
-#include <memory>
 #include <cmath>
+#include <memory>
 
 #include "Tests/TestTools.h"
 
-#include "MaterialLib/Fluid/Density/createFluidDensityModel.h"
-#include "MaterialLib/Fluid/Viscosity/createViscosityModel.h"
+#include "BaseLib/ConfigTree.h"
+
+#include "MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h"
 #include "MaterialLib/Fluid/FluidProperties/FluidProperties.h"
-#include "MaterialLib/Fluid/FluidProperties/PrimaryVariableDependentFluidProperties.h"
 
 using namespace MaterialLib;
 using namespace MaterialLib::Fluid;
+
 using ArrayType = MaterialLib::Fluid::FluidProperty::ArrayType;
 
-template <typename F>
-std::unique_ptr<FluidProperty> createTestModel(const char xml[], F func,
-                                               const std::string& key)
+std::unique_ptr<FluidProperties> createTestFluidProperties(const char xml[])
 {
     auto const ptree = readXml(xml);
     BaseLib::ConfigTree conf(ptree, "", BaseLib::ConfigTree::onerror,
                              BaseLib::ConfigTree::onwarning);
-    auto const& sub_config = conf.getConfigSubtree(key);
-    return func(sub_config);
+    auto const& sub_config = conf.getConfigSubtree("fluid");
+    return createFluidProperties(sub_config);
 }
 
-TEST(MaterialFluidModel, checkCompositeDensityViscosityModel)
+TEST(MaterialFluidProperties, checkPrimaryVariableDependentFluidProperties)
 {
-    const char xml_d[] =
-        "<density>"
-        "   <type>TemperatureDependent</type>"
-        "   <temperature0> 293.0 </temperature0> "
-        "   <beta> 4.3e-4 </beta> "
-        "   <rho0>1000.</rho0>"
-        "</density>";
-
-    auto rho = createTestModel(xml_d, createFluidDensityModel, "density");
-
-    const char xml_v[] =
-        "<viscosity>"
-        "  <type>TemperatureDependent</type>"
-        "  <mu0>1.e-3 </mu0>"
-        "   <tc>293.</tc>"
-        "   <tv>368.</tv>"
-        "</viscosity>";
-    auto mu = createTestModel(xml_v, createViscosityModel, "viscosity");
+    const char xml[] =
+        "<fluid>"
+        "    <density>"
+        "       <type>TemperatureDependent</type>"
+        "       <temperature0> 293.0 </temperature0> "
+        "       <beta> 4.3e-4 </beta> "
+        "       <rho0>1000.</rho0>"
+        "    </density>"
+        "    <viscosity>"
+        "       <type>TemperatureDependent</type>"
+        "       <mu0>1.e-3 </mu0>"
+        "       <tc>293.</tc>"
+        "       <tv>368.</tv>"
+        "    </viscosity>"
+        "</fluid>";
 
-    std::unique_ptr<FluidProperties> fluid_model =
-        std::unique_ptr<FluidProperties>(
-            new PrimaryVariableDependentFluidProperties(
-                std::move(rho), std::move(mu), nullptr, nullptr));
+    auto const fluid_model = createTestFluidProperties(xml);
 
     ArrayType vars;
     vars[0] = 350.0;
-- 
GitLab