public void FormulatrixRepo_RegisterRetrieveGettype_Arbitrary_Invalid_Item_Name([Values("test8,test", "test8/test", ".test8test", "test8.test")] string inputName)
        {
            string inputContent = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend! - Test 8</body></note>";
            int    contentType  = 2;

            try
            {
                FormulatrixRepo <string> .Register(inputName, inputContent, contentType);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("is invalid name", e.Message);
            }

            try
            {
                FormulatrixRepo <string> .Retrieve <string>(inputName);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("is invalid name", e.Message);
            }

            try
            {
                FormulatrixRepo <string> .GetType(inputName);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("is invalid name", e.Message);
            }
        }
        public void FormulatrixRepo_Gettype_Arbitrary_Unregistered_Item()
        {
            string inputName   = "test5";
            int    contentType = FormulatrixRepo <string> .GetType(inputName);

            Assert.AreEqual(0, contentType);
        }
Example #3
0
        static void Main(string[] args)
        {
            int argsLength = args.Length;

            if (argsLength != 2 && argsLength != 4)
            {
                Console.WriteLine("Need 2 or 5 args");
                Console.WriteLine("ConsoleApp1.exe [method] [item_name] [input] [item_type]");
                Console.WriteLine("method: register/gettype/retrieve/deregister");
                Console.WriteLine("item_name: string");
                Console.WriteLine("input content/text");
                Console.WriteLine("item_type 1 or 2 (1 for JSON, 2 for XML.");
            }

            if (argsLength == 0)
            {
                return;
            }

            if ((args[0].Equals("retrieve") || args[0].Equals("gettype") || args[0].Equals("deregister")) && argsLength != 2)
            {
                Console.WriteLine("Need 2 args to {0}", args[0]);
                return;
            }
            else if (args[0].Equals("register") && argsLength != 4)
            {
                Console.WriteLine("Need 4 args to register.");
                return;
            }

            if (args[0].Equals("retrieve"))
            {
                Console.WriteLine("Retrieve: {0} -> {1}", args[1], FormulatrixRepo <string> .Retrieve <string>(args[1]));
            }
            else if (args[0].Equals("gettype"))
            {
                Console.WriteLine("Gettype: {0} -> {1}", args[1], FormulatrixRepo <string> .GetType(args[1]));
            }
            else if (args[0].Equals("deregister"))
            {
                FormulatrixRepo <string> .Deregister(args[1]);

                Console.WriteLine("Deregister: {0} -> Done", args[1]);
            }
            else if (args[0].Equals("register"))
            {
                int contentType = 0;
                Int32.TryParse(args[3], out contentType);
                FormulatrixRepo <string> .Register(args[1], args[2], contentType);

                Console.WriteLine("Register: {0} -> Done", args[1]);
            }
            else
            {
                Console.WriteLine("Unknown method of {0}", args[1]);
            }
        }
        public void FormulatrixRepo_Retrieve_Arbitrary_Unregistered_Item()
        {
            string inputName = "test6";

            try
            {
                string content = FormulatrixRepo <string> .Retrieve <string>(inputName);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("doesn't exist", e.Message);
            }
        }
        public void FormulatrixRepo_Deregister_Arbitrary_Unregistered_Item()
        {
            string inputName = "test7";

            try
            {
                FormulatrixRepo <string> .Deregister(inputName);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("doesn't exist", e.Message);
            }
        }
        public void FormulatrixRepo_Register_Then_Gettype_Then_Deregister()
        {
            string inputName        = "test4";
            int    inputContentType = 1;
            string inputContent     = "{\"test4\" : \"test4\"}";

            FormulatrixRepo <string> .Register(inputName, inputContent, inputContentType);

            int outputContentType = FormulatrixRepo <string> .GetType(inputName);

            // deregister so that this test case can repeated due to existance of an item
            FormulatrixRepo <string> .Deregister(inputName);

            Assert.AreEqual(inputContentType, outputContentType);
        }
        public void FormulatrixRepo_Register_Then_Retrieve_Int_Then_Deregister()
        {
            string inputName        = "test3";
            int    inputContentType = 1;
            int    inputContent     = 333;

            FormulatrixRepo <int> .Register(inputName, inputContent, inputContentType);

            int outputContent = FormulatrixRepo <int> .Retrieve <int>(inputName);

            // deregister so that this test case can repeated due to existance of an item
            FormulatrixRepo <int> .Deregister(inputName);

            Assert.AreEqual(inputContent, outputContent);
        }
        public void FormulatrixRepo_Register_Then_Retrieve_String_Then_Deregister()
        {
            string inputName        = "test2";
            int    inputContentType = 1;
            string inputContent     = "{\"test2\" : \"test2\"}";

            FormulatrixRepo <string> .Register(inputName, inputContent, inputContentType);

            string outputContent = FormulatrixRepo <string> .Retrieve <string>(inputName);

            // deregister so that this test case can repeated due to existance of an item
            FormulatrixRepo <string> .Deregister(inputName);

            Assert.AreEqual(inputContent, outputContent);
        }
        public void FormulatrixRepo_Register_Then_Deregister([Values("test1", "test_1")] string inputName)
        {
            int inputContentType = 1;

            // will create test1.json file
            string inputContent = "{\"test1\" : \"test1\"}";

            FormulatrixRepo <string> .Register(inputName, inputContent, inputContentType);

            // check file existance
            Assert.IsTrue(System.IO.File.Exists(inputName + ".json"));

            // deregister so that this test case can be repeated due to existance of an item
            FormulatrixRepo <string> .Deregister(inputName);
        }
        public void FormulatrixRepo_Register2x_Item()
        {
            string inputName    = "test9";
            string inputContent = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend! - Test 9</body></note>";
            int    contentType  = 2;

            try
            {
                FormulatrixRepo <string> .Register(inputName, inputContent, contentType);

                FormulatrixRepo <string> .Register(inputName, inputContent, contentType);
            }
            catch (System.Exception e)
            {
                StringAssert.Contains("already exists", e.Message);
            }
            finally
            {
                FormulatrixRepo <string> .Deregister(inputName);
            }
        }