public void AbleToGetNextConceptBean()
        {
            SCTIdRepository Repo = new SCTIdRepository(1234567);

            Repo.ReserveId("88888881234567101");
            int NextBean = Repo.GetNextBean("Concept", 1234567);

            Assert.AreEqual(8888889, NextBean);
        }
        public void RepoIsCreatedSuccessfuly()
        {
            System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            if (File.Exists(RepoFile))
            {
                File.Delete(RepoFile);
            }
            SCTIdRepository Repo = new SCTIdRepository(1234567);

            Assert.IsTrue(File.Exists(RepoFile));
        }
        public void RepoIsSuccesfullyDumped()
        {
            System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            if (File.Exists(RepoDump))
            {
                File.Delete(RepoDump);
            }
            SCTIdRepository Repo = new SCTIdRepository(1234567);

            Repo.DumpRepository();

            Assert.IsTrue(File.Exists(RepoDump));
        }
        public void AbleToReserveConceptId()
        {
            var             ID   = "11234567100";
            SCTIdRepository Repo = new SCTIdRepository(1234567);

            try
            {
                Repo.ReserveId(ID);
                Assert.IsTrue(true);
            }
            catch (Exception)
            {
                Assert.Fail("Unable to reserve ID: {0}", ID);
            }
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            int             ns   = 1223221;
            SCTIdGenerator  foo  = new SCTIdGenerator(ns);
            SCTIdRepository Repo = new SCTIdRepository(ns);

            Console.WriteLine("NameSpace =" + ns.ToString());


            string bar = foo.GenerateConceptId().ToString();

            Console.WriteLine("ConceptId =" + bar);
            Repo.ReserveId(bar);
            bar = foo.GenerateConceptId().ToString();
            Console.WriteLine("ConceptId =" + bar);
            Repo.ReserveId(bar);
            bar = foo.GenerateConceptId().ToString();
            Console.WriteLine("ConceptId =" + bar);
            Repo.ReserveId(bar);

            Console.WriteLine();
            bar = foo.GenerateDescriptionId().ToString();
            Console.WriteLine("DescriptionId =" + bar);
            Repo.ReserveId(bar);

            Console.WriteLine();
            bar = foo.GenerateRelationshipId().ToString();
            Console.WriteLine("RelationshipId =" + bar);
            Repo.ReserveId(bar);

            string codeString = "0123456789";

            string beep = codeString.Substring(codeString.Length - 6, 3);

            Console.WriteLine("This should be 456 : " + beep);
            Console.WriteLine("48176007 has check digit = " + Verhoeff.GenerateVerhoeff("4817600"));

            Repo.DumpRepository();
            Console.WriteLine("Repo Dumped.");

            Console.ReadKey();
        }
        public void RepoIsSuccesfullyImported()
        {
            System.IO.Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
            if (File.Exists(RepoDump))
            {
                File.Delete(RepoDump);
            }
            SCTIdRepository Repo = new SCTIdRepository(1234567);

            string usedIds    = "TestFileDump.txt";
            Random foo        = new Random();
            int    RandomBean = foo.Next(999999);

            //write generate a random bean, and write a bogus ID to the file.
            File.WriteAllText(usedIds, RandomBean + "1234567121");

            //import that file
            Repo.ImportAllocatedSCTIds(usedIds);
            //and get the next been..
            //which should be 1 more than the random bean inserted above.
            Assert.IsTrue(Repo.GetNextBean("Relationship", 1234567) == RandomBean + 1);
        }