Esempio n. 1
0
        public void Dedupe_Test01()
        {
            List <SpecialtyAliasAndType> specialtiesAliasesAndTypes = new List <SpecialtyAliasAndType>();
            int index;

            //Dedupe empty list
            specialtiesAliasesAndTypes = Specialties.DeDupe(specialtiesAliasesAndTypes);
            Assert.AreEqual(0, specialtiesAliasesAndTypes.Count);

            //Dedupe one entry list
            specialtiesAliasesAndTypes.Add(new SpecialtyAliasAndType
            {
                Alias     = "sp1",
                EntryType = EntryTypes.Specialty,
                Specialty = null
            });
            specialtiesAliasesAndTypes = Specialties.DeDupe(specialtiesAliasesAndTypes);
            Assert.AreEqual(1, specialtiesAliasesAndTypes.Count);
            index = 0;
            Assert.AreEqual("sp1", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Specialty, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual(null, specialtiesAliasesAndTypes[index].Specialty);

            //Dedupe three entry list
            specialtiesAliasesAndTypes.Add(new SpecialtyAliasAndType
            {
                Alias     = "a2",
                EntryType = EntryTypes.Alias,
                Specialty = "sp2"
            });
            specialtiesAliasesAndTypes.Add(new SpecialtyAliasAndType
            {
                Alias     = "su1",
                EntryType = EntryTypes.Subspecialty,
                Specialty = "sp2"
            });
            specialtiesAliasesAndTypes = Specialties.DeDupe(specialtiesAliasesAndTypes);
            Assert.AreEqual(3, specialtiesAliasesAndTypes.Count);
            index = 0;
            Assert.AreEqual("sp1", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Specialty, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual(null, specialtiesAliasesAndTypes[index].Specialty);
            index++;
            Assert.AreEqual("a2", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Alias, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual("sp2", specialtiesAliasesAndTypes[index].Specialty);
            index++;
            Assert.AreEqual("su1", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Subspecialty, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual("sp2", specialtiesAliasesAndTypes[index].Specialty);

            //Dedupe multiple entry list
            specialtiesAliasesAndTypes.Add(new SpecialtyAliasAndType
            {
                Alias     = "a2",
                EntryType = EntryTypes.Alias,
                Specialty = "sp2"
            });
            specialtiesAliasesAndTypes.Add(new SpecialtyAliasAndType
            {
                Alias     = "su1",
                EntryType = EntryTypes.Subspecialty,
                Specialty = "sp2"
            });
            specialtiesAliasesAndTypes = Specialties.DeDupe(specialtiesAliasesAndTypes);
            Assert.AreEqual(3, specialtiesAliasesAndTypes.Count);
            index = 0;
            Assert.AreEqual("sp1", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Specialty, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual(null, specialtiesAliasesAndTypes[index].Specialty);
            index++;
            Assert.AreEqual("a2", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Alias, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual("sp2", specialtiesAliasesAndTypes[index].Specialty);
            index++;
            Assert.AreEqual("su1", specialtiesAliasesAndTypes[index].Alias);
            Assert.AreEqual(EntryTypes.Subspecialty, specialtiesAliasesAndTypes[index].EntryType);
            Assert.AreEqual("sp2", specialtiesAliasesAndTypes[index].Specialty);
        }