public void GetFactorTreesByIdsAndSearchCriteria() { List <int> factorIds = new List <int> { 985 }; FactorTreeSearchCriteria searchCriteria = new FactorTreeSearchCriteria { FactorIds = factorIds }; FactorTreeNodeList factorTrees; factorTrees = GetFactorDataSource().GetFactorTrees(GetUserContext(), searchCriteria); Assert.IsNotNull(factorTrees); Assert.IsTrue(factorTrees.IsNotEmpty()); Assert.AreEqual(factorTrees.Count, 1); Assert.AreEqual(factorTrees[0].Id, 985); }
/// <summary> /// Save UserDataSet to xml file. /// </summary> /// <param name='fileName'>File name.</param> /// <param name='userDataSet'>UserDataSet to save.</param> /// <param name='dictionaryURI'>Path.</param> /// <param name='renewCommonDefinitions'>Indicates if common definitions should be updated.</param> public static void Serialize(String fileName, UserDataSet userDataSet, String dictionaryURI, Boolean renewCommonDefinitions) { BinaryFormatter formatter = new BinaryFormatter(); Stream stream = File.OpenWrite(fileName); formatter.Serialize(stream, userDataSet); stream.Close(); if (renewCommonDefinitions) { String factorFileName = dictionaryURI + @"\Factors.bin"; stream = File.OpenWrite(factorFileName); FactorList allFactors = FactorManager.GetFactors(); formatter.Serialize(stream, allFactors); stream.Close(); FactorTreeSearchCriteria searchCriteria = new FactorTreeSearchCriteria(); FactorTreeNodeList factorTrees = new FactorTreeNodeList(); foreach (Factor factor in allFactors) { List <Int32> factorIds = new List <Int32>(); factorIds.Add(factor.Id); searchCriteria.RestrictSearchToFactorIds = factorIds; } String factorTreeFileName = dictionaryURI + @"\FactorTrees.bin"; stream = File.OpenWrite(factorTreeFileName); formatter.Serialize(stream, factorTrees); stream.Close(); String speciesFactQualityFileName = dictionaryURI + @"\SpeciesFactQualities.bin"; stream = File.OpenWrite(speciesFactQualityFileName); formatter.Serialize(stream, SpeciesFactManager.GetSpeciesFactQualities()); stream.Close(); String periodsFileName = dictionaryURI + @"\Periods.bin"; stream = File.OpenWrite(periodsFileName); formatter.Serialize(stream, PeriodManager.GetPeriods()); stream.Close(); } }