public void FoodDesToIngredientTest_ShouldConvertFOOD_DES_objectToIngreadientObjectWithAllParameters()
{
//arrange
USDADataImport.FOOD_DES food1 = new USDADataImport.FOOD_DES
{
NDB_No = "1",
FdGrp_Cd = "0100", //Dairy and Egg Products
Long_Desc = "Long_Desc",
Shrt_Desc = "Shrt_Desc",
ComName = "ComName",
ManufacName = "ManufacName",
Ref_Desc = "Ref_Desc",
Refuse = 0,
SciName = "SciName",
N_Factor = 0,
Pro_Factor = 0,
Fat_Factor = 0,
CHO_Factor = 0,
NUT_DATA = new List<NUT_DATA>(),
WEIGHT = new List<WEIGHT>(),
LANGDESC = new List<LANGDESC>()
};
NUT_DATA NutData1 = new NUT_DATA
{
NDB_No = "1",
Nutr_No = "203",
Nutr_Val = 101,
Num_Data_Pts = 1,
Std_Error = 1,
Src_Cd = "Src_Cd",
Deriv_Cd = "Deriv_Cd",
Ref_NDB_No = "Ref_NDB_No",
Add_Nutr_Mark = "Add_Nutr_Mark",
Num_Studies = 1,
Min = 101,
Max = 201,
DF = 1,
Low_EB = 1,
Up_EB = 1,
Stat_Cmt = "Stat_Cmt",
AddMod_Date = "12/2013",
};
NUT_DATA NutData2 = new NUT_DATA
{
NDB_No = "1",
Nutr_No = "205",
Nutr_Val = 102,
Num_Data_Pts = 2,
Std_Error = 2,
Src_Cd = "Src_Cd",
Deriv_Cd = "Deriv_Cd",
Ref_NDB_No = "Ref_NDB_No",
Add_Nutr_Mark = "Add_Nutr_Mark",
Num_Studies = 2,
Min = 102,
Max = 202,
DF = 2,
Low_EB = 2,
Up_EB = 2,
Stat_Cmt = "Stat_Cmt",
AddMod_Date = "12/2013",
};
NUT_DATA NutData3 = new NUT_DATA
{
NDB_No = "1",
Nutr_No = "210",
Nutr_Val = 103,
Num_Data_Pts = 3,
Std_Error = 3,
Src_Cd = "Src_Cd",
Deriv_Cd = "Deriv_Cd",
Ref_NDB_No = "Ref_NDB_No",
Add_Nutr_Mark = "Add_Nutr_Mark",
Num_Studies = 3,
Min = 103,
Max = 203,
DF = 3,
Low_EB = 3,
Up_EB = 3,
Stat_Cmt = "Stat_Cmt",
AddMod_Date = "12/2013",
};
food1.NUT_DATA.Add(NutData1);
food1.NUT_DATA.Add(NutData2);
food1.NUT_DATA.Add(NutData3);
WEIGHT weight1 = new WEIGHT
{
NDB_No = "1",
Seq = "1",
Amount = 1,
Msre_Desc = "stick",
Gm_Wgt = 21
};
WEIGHT weight2 = new WEIGHT
{
NDB_No = "1",
Seq = "2",
Amount = 2,
Msre_Desc = "serving 5 sticks",
Gm_Wgt = 107
};
food1.WEIGHT.Add(weight1);
food1.WEIGHT.Add(weight2);
List<FD_GROUP> food_groups = new List<FD_GROUP>();
food_groups.Add(new FD_GROUP { FdGrp_CD = "0100", FdGrp_Desc = "Dairy and Egg Products" });
food_groups.Add(new FD_GROUP { FdGrp_CD = "0200", FdGrp_Desc = "Spices and Herbs" });
food_groups.Add(new FD_GROUP { FdGrp_CD = "0300", FdGrp_Desc = "Baby Foods" });
//act
USDAImport usdaImport = new USDAImport();
Ingredient ingredient = usdaImport.FoodDesToIngredient(food1, food_groups);
//assert
Assert.IsNotNull(ingredient);
Assert.IsNotNull(ingredient.NutritionFacts);
Assert.IsNotNull(ingredient.NutritionFacts.FullNutrisionList);
Assert.AreEqual(ingredient.NutritionFacts.FullNutrisionList.Count, 3);
Assert.IsNotNull(ingredient.Weigts);
Assert.AreEqual(ingredient.Weigts.Count, 2);
Assert.AreEqual((int)ingredient.FoodGrp, 0100);
}