Пример #1
0
 public Story(string storyid = null, long timestamp = -1, string permalink = null, Author author = null, string subject = null, string body = null)
 {
     this.key = "storyid";
     this.storyid = storyid;
     this.timestamp = (timestamp == -1) ? (new Time(timestamp)).Unix : timestamp;
     this.permalink = permalink;
     this.author = author;
     this.subject = subject;
     this.body = body;
 }
Пример #2
0
        private static void testErase()
        {
            Author foobar = new Author(handle:"foobar");
            Author anon = new Author();
            Tester.inline(true == Storage.erase(foobar),  "Erase Author `{0}'", foobar);
            Tester.inline(false == Storage.erase(foobar), "Erase Author `{0}' (already erased) should return false", foobar);
            Tester.inline(false == Storage.erase(anon),   "Erase Author `{0}' (non-existent) should return false", anon);

            Tester.inline(true == Storage.put(anon), "Adding Author `{0}' to test parameterized erasure", anon);
            Tester.inline(true == Storage.erase(new Author(), "handle=?", new OdbcParameter("handle", anon)),
                "Erase Author `{0}' (non-existent) should return false", anon);
        }
Пример #3
0
 private static void testPut()
 {
     Author author = new Author("foo", "bar", "foobar", "foo@bar");
     Tester.inline(Storage.put(author), "Attempting to store Author `foobar'");
     Tester.inline(Storage.exists(author), "Check for existence of Author `foobar'");
 }
Пример #4
0
        private static void __CreateStory(string ignore)
        {
            long timestamp = new Time().Unix;
            string permalink = String.Format("/blog/html/cs{0}.html", timestamp);
            Author author = new Author(handle: "bazile");

            // Generate a unique id
            string storyid = BitConverter.ToString( MD5.Create().ComputeHash(BitConverter.GetBytes(timestamp)) ).Replace("-", "").Substring(0,16).ToLower(); // TODO uniqid
            string subject;

            Console.Write("Subject: ");
            subject = Console.ReadLine();

            // Compose the body
            string body = "";
            string line = "";
            string lastLine = "";
            bool eof = false;
            Console.WriteLine("Body (enter two blank lines to signify EOF):");
            do {
                lastLine = line;
                line = Console.ReadLine();
                body = String.Format("{0}\n{1}", body, line);
                eof = (lastLine == "" && line == "");
            } while (! eof);

            bool success = Storage.put(new Story(storyid, timestamp, permalink, author, subject, body));
            Console.WriteLine("Operation {0}", (success) ? "Successful" : "Failed");
        }