Esempio n. 1
0
        public void TestChildren()
        {
            List <string>    code = new List <string>();
            List <string>    name = new List <string>();
            InstitutionClass inst = u.createInstitution("COD", "INST");

            for (int i = 0; i < 10; ++i)
            {
                string           c = "Code" + i;
                string           n = "Name" + i;
                InstitutionClass k = inst.createChild(c, n);
                code.Add(c);
                name.Add(n);
                Assert.AreEqual(c, k.GetCode());
                Assert.AreEqual(n, k.GetName());
            }
            IReadOnlyCollection <InstitutionClass> insts = inst.GetChildren();

            Assert.AreEqual(10, insts.Count);
            foreach (InstitutionClass t in insts)
            {
                int idx = code.IndexOf(t.GetCode());
                Assert.GreaterOrEqual(idx, 0);
                code[idx] = "-----";
            }
        }
        public void TestInstitutionsCreation()
        {
            List <string> code = new List <string>();
            List <string> name = new List <string>();

            for (int i = 0; i < 10; ++i)
            {
                code.Add("INST" + i);
                name.Add("NAME" + i);
                InstitutionClass inst = u.createInstitution(code[i], name[i]);
                Assert.IsNotNull(inst);
                Assert.AreEqual(inst.GetName(), name[i]);
                Assert.AreEqual(inst.GetCode(), code[i]);
            }
            int c = 0;

            foreach (InstitutionClass inst in u.getInstitutions())
            {
                int idx = code.IndexOf(inst.GetCode());
                Assert.AreEqual(idx >= 0, true);
                code[idx] = "----";
                c         = c + 1;
            }
            Assert.AreEqual(10, c);
        }
Esempio n. 3
0
        public void TestInstitutionCreation()
        {
            InstitutionClass inst = new InstitutionClass("ABC", "B", u);

            Assert.AreEqual("ABC", inst.GetCode());
            Assert.AreEqual("B", inst.GetName());
            Assert.AreEqual(u, inst.GetUniversity());
        }
Esempio n. 4
0
 public void TestInstitutionCodeLenLT3()
 {
     Assert.Throws <Exception>(delegate {
         InstitutionClass i = new InstitutionClass("A", "B", u);
     });
     Assert.Throws <Exception>(delegate {
         InstitutionClass i = new InstitutionClass("AB", "B", u);
     });
 }
Esempio n. 5
0
        public void TestUniqueCode()
        {
            InstitutionClass i1 = u.createInstitution("COD1", "NAME1");
            InstitutionClass i2 = u.createInstitution("COD2", "NAME2");

            Assert.Throws <Exception>(delegate {
                i1.createChild("COD1", "NAME3");
            });
            Assert.Throws <Exception>(delegate {
                i2.createChild("COD1", "NAME3");
            });
        }
        public void TestFirstInstitutionCreation()
        {
            InstitutionClass i = u.createInstitution("AVX", "ABC");

            Assert.IsNotNull(i);
            Assert.AreEqual("AVX", i.GetCode());
            Assert.AreEqual("ABC", i.GetName());
            int c = 0;

            foreach (InstitutionClass x in u.getInstitutions())
            {
                Assert.AreEqual(x, i);
                c = c + 1;
            }
            Assert.AreEqual(1, c);
        }