A post made to Delicious.
Esempio n. 1
0
        public void Create()
        {
            String address = "http://example.com/";
            String hash = "a5a6f3d28d8dd549f3cad39fb0b34104";
            String description = "Example web page";
            String tags = "example testing domain test";
            String date = "2008-12-12T07:45:52Z";
            String extended = "These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.";
            String meta = "fa2a46d239ad4f089c3ce7961d958b2e";

            Post post = new Post(address, hash, description, tags, extended, date, meta);

            Assert.AreEqual(address, post.Address);
            Assert.AreEqual(hash, post.Hash);
            Assert.AreEqual(description, post.Description);

            Assert.AreEqual(4, post.Tags.Count);
            Assert.IsTrue(post.Tags.Contains("example"));
            Assert.IsTrue(post.Tags.Contains("testing"));
            Assert.IsTrue(post.Tags.Contains("domain"));
            Assert.IsTrue(post.Tags.Contains("test"));

            Assert.AreEqual(new DateTime(2008, 12, 12, 7, 45, 52), post.Date);
            Assert.AreEqual(extended, post.Extended);
            Assert.AreEqual(meta, post.Meta);
        }
        private string TranslateQuery(ParameterExpression lambdaParameter, Expression clauses)
        {
            // from post in queryable
            // where post.Date == <evaluated comparedDate>

            // i.e. queryable.Where(post => post.Date == <evaluated comparedDate>)

            // TODO: This should probably be mocked instead of using a meaningless array.
            // See the TODO below - it probably relates.
            IQueryable<Post> queryable = new Post[] { }.AsQueryable<Post>();

            // queryable.Where( ... )
            MethodCallExpression whereCall = Expression.Call(
                typeof(Queryable),
                "Where",
                new Type[] { typeof(Post) },
                queryable.Expression,
                Expression.Lambda<Func<Post, bool>>(clauses, new ParameterExpression[] { lambdaParameter }));

            // TODO: Double check that queryable.Expression gives us what we want above
            // Debug output says it results in a Post[], but I thought it should be an IQueryable<Post>
            // This argument isn't used in the translator at the moment.

            QueryTranslator translator = new QueryTranslator(whereCall);

            return translator.Translate();
        }
Esempio n. 3
0
        public void HashCode()
        {
            String address = "http://example.com/";
            String hash = "a5a6f3d28d8dd549f3cad39fb0b34104";
            String description = "Example web page";
            String tags = "example testing domain test";
            String date = "2008-12-12T07:45:52Z";
            String extended = "These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.";
            String meta = "fa2a46d239ad4f089c3ce7961d958b2e";

            Post post1 = new Post(address, hash, description, tags, extended, date, meta);
            Post post2 = new Post(address, hash, description, tags, extended, date, meta);
            Post post3 = new Post("address", hash, description, tags, extended, date, meta);
            Post post4 = new Post(address, "hash", description, tags, extended, date, meta);
            Post post5 = new Post(address, hash, "description", tags, extended, date, meta);
            Post post6 = new Post(address, hash, description, "tags", extended, date, meta);
            Post post7 = new Post(address, hash, description, tags, "extended", date, meta);
            Post post8 = new Post(address, hash, description, tags, extended, "1999-10-10T01:01:01Z", meta);
            Post post9 = new Post(address, hash, description, tags, extended, date, "meta");

            Assert.AreEqual(post1.GetHashCode(), post2.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post3.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post4.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post5.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post6.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post7.GetHashCode());
            Assert.AreNotEqual(post1.GetHashCode(), post8.GetHashCode());
        }
Esempio n. 4
0
        public void Equal()
        {
            String address = "http://example.com/";
            String hash = "a5a6f3d28d8dd549f3cad39fb0b34104";
            String description = "Example web page";
            String tags = "example testing domain test";
            String date = "2008-12-12T07:45:52Z";
            String extended = "These domain names are reserved for use in documentation and are not available for registration. See RFC 2606, Section 3.";
            String meta = "fa2a46d239ad4f089c3ce7961d958b2e";

            Post post1 = new Post(address, hash, description, tags, extended, date, meta);
            Post post2 = new Post(address, hash, description, tags, extended, date, meta);

            Assert.AreEqual(post1, post2);
        }