Exemplo n.º 1
0
        public static void UnitTest()
        {
            HlaMsr1Factory   hlaMsr1Factory = HlaMsr1Factory.GetFactory(new int[] { 4, 4, 4 });
            HashSet <string> warningSet     = new HashSet <string>();

            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234/B23", ref warningSet).ToString() == "B1234/B23");
            hlaMsr1Factory.GetGroundOrAbstractInstance("BND", ref warningSet);
            Hla hla5 = hlaMsr1Factory.GetGroundOrAbstractInstance("B", ref warningSet);

            SpecialFunctions.CheckCondition(hla5.ToString() == "B");
            Hla hla3 = hlaMsr1Factory.GetGroundOrAbstractInstance("C1234", ref warningSet);

            SpecialFunctions.CheckCondition(hla3.ToString() == "C1234");
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234", ref warningSet).ToString() == "B1234");
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("C1234/C12/C", ref warningSet).ToString() == "C");
            Hla hla7 = hlaMsr1Factory.GetGroundOrAbstractInstance("C1234N", ref warningSet);

            SpecialFunctions.CheckCondition(hla7.ToString() == "C1234");
            Hla hla6 = hlaMsr1Factory.GetGroundOrAbstractInstance("C12", ref warningSet);

            SpecialFunctions.CheckCondition(hla6.ToString() == "C12");
            Hla hla1 = hlaMsr1Factory.GetGroundOrAbstractInstance("A74", ref warningSet);

            SpecialFunctions.CheckCondition(hla1.ToString() == "A74");
            Hla hla2 = hlaMsr1Factory.GetGroundOrAbstractInstance("A7412", ref warningSet);

            SpecialFunctions.CheckCondition(hla2.ToString() == "A74");
            SpecialFunctions.CheckCondition(hla6.IsMoreGeneralThan(hla7));  // assert
            SpecialFunctions.CheckCondition(!hla6.IsMoreGeneralThan(hla2)); // assert
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("A12345678", ref warningSet).ToString() == "A1234");
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B95", ref warningSet).ToString() == "B15");
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("B15/B9512", ref warningSet).ToString() == "B15");
            Hla hla4 = hlaMsr1Factory.GetGroundOrAbstractInstance("A02/A9299", ref warningSet);

            SpecialFunctions.CheckCondition(hla4.ToString() == "A02");
            SpecialFunctions.CheckCondition(hla3.IsGround);  // assert
            SpecialFunctions.CheckCondition(hla1.IsGround);  // assert
            SpecialFunctions.CheckCondition(!hla4.IsGround); // assert
            SpecialFunctions.CheckCondition(!hla5.IsGround); // assert
            SpecialFunctions.CheckCondition(hlaMsr1Factory.GetGroundOrAbstractInstance("A1200", ref warningSet).ToString() == "A12");
            SpecialFunctions.CheckCondition(!hlaMsr1Factory.GetGroundOrAbstractInstance("B*1234/B23", ref warningSet).IsGround);
        }
Exemplo n.º 2
0
        static private Dictionary <string, Ethnicity> Init()
        {
            Dictionary <string, Ethnicity> ethnicityNameToEthnicity = new Dictionary <string, Ethnicity>();

            using (TextReader textReader = Linkdis.OpenResource("datafileList.txt"))
            {
                foreach (var row in SpecialFunctions.ReadDelimitedFile(textReader, new { Ethnicity = "", Class = "", HlaLengthList = "", FileName = "" }, new char[] { '\t' }, true))
                {
                    Ethnicity ethnicity          = ethnicityNameToEthnicity.GetValueOrDefault(row.Ethnicity.ToLowerInvariant());
                    EClass    eclass             = ethnicity.HlaClassNameToEClass.GetValueOrDefault(row.Class);
                    var       hlaLengthListQuery =
                        from hlaLengthAsString in row.HlaLengthList.Split(' ')
                        select int.Parse(hlaLengthAsString);

                    LinkedList1 <int> hlaLengthList = LinkedList1 <int> .GetInstanceFromList(hlaLengthListQuery.ToList());


                    TableInfo tableInfo = eclass.HlaLengthListToTableInfo.GetValueOrDefault(hlaLengthList);
                    tableInfo.HlaMsr1Factory = HlaMsr1Factory.GetFactory(hlaLengthList);
                    tableInfo.LoadTable(row.FileName, row.Class);
                }
            }
            return(ethnicityNameToEthnicity);
        }