Ejemplo n.º 1
0
        public void GetDbvItemViaWebClient()
        {
            // get specific version
            var url = "dbv://rules:2/test%20with%20spaces/dummy.csv";

            var repository = new DbvItemRepository(new DbvItemMemoryStore());
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("first checkin"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("third checkin"), "Checking", "john doe");

            RepositoryLocator.Repository = repository;

            //WebRequest.RegisterPrefix("dbv", new DbvRequestCreator(RepositoryLocator));

            var wc = new WebClient();
            var result = wc.DownloadString(url);

            Console.Out.WriteLine("result = {0}", result);
            Assert.AreEqual("HELLO WORLD", result);

            Assert.Contains("X-DBV-Revision",wc.ResponseHeaders.AllKeys);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Revision'] = {0}", wc.ResponseHeaders["X-DBV-Revision"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Comments'] = {0}", wc.ResponseHeaders["X-DBV-Comments"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Name'] = {0}", wc.ResponseHeaders["X-DBV-Name"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Timestamp'] = {0}", wc.ResponseHeaders["X-DBV-Timestamp"]);
            Console.Out.WriteLine("wc.ResponseHeaders['Content-Type'] = {0}", wc.ResponseHeaders["Content-Type"]);

            // NO ASYNC IMPLEMENTATION
            /*
            var t = wc.DownloadStringTaskAsync(url);
            Console.Out.WriteLine("t.Result = {0}", t.Result);
            */
        }
        public void CheckinNewDbvItem()
        {
            var repository = new DbvItemRepository(new DbvItemMemoryStore());

            var latestRev = repository.Checkin("/test/dummy.csv", null, "comment", "jane doe");
            Assert.Greater(latestRev, 0);
            // checkin item again and verify that revision number increased

            var latestRev1 = repository.Checkin("/test/dummy.csv", null, "comment", "jane doe");
            Assert.AreEqual(latestRev + 1, latestRev1);
        }
Ejemplo n.º 3
0
        public void CheckinNewDbvItem()
        {
            var repository = new DbvItemRepository(new DbvItemMemoryStore());

            var latestRev = repository.Checkin("/test/dummy.csv", null, "comment", "jane doe");

            Assert.Greater(latestRev, 0);
            // checkin item again and verify that revision number increased

            var latestRev1 = repository.Checkin("/test/dummy.csv", null, "comment", "jane doe");

            Assert.AreEqual(latestRev + 1, latestRev1);
        }
Ejemplo n.º 4
0
        public void GetDbvItemViaWebClientUnknownItem()
        {
            // get specific version
            var url = "dbv://rules:2/test/dummy.csv";

            var repository = new DbvItemRepository(new DbvItemMemoryStore());

            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("first checkin"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("third checkin"), "Checking", "john doe");

            RepositoryLocator.Repository = repository;

            //WebRequest.RegisterPrefix("dbv", new DbvRequestCreator(RepositoryLocator));


            var wc     = new WebClient();
            var result = wc.DownloadString(url);
        }
Ejemplo n.º 5
0
        public void CheckinByNameAndParameters()
        {
            var currentRevision = Repository.Checkout("/test/dummy.csv");

            var content  = Encoding.ASCII.GetBytes("abcdefg");
            var revision = Repository.Checkin("/test/dummy.csv", content, "checkin comment", "john doe");

            Assert.Greater(revision, currentRevision.Revision);

            // and get it back
            var latest = Repository.Checkout("/test/dummy.csv");

            Assert.AreEqual("john doe", latest.Author);
            Assert.AreEqual(content, latest.Content);
            Assert.AreEqual("checkin comment", latest.Comments);
        }
Ejemplo n.º 6
0
        public void GetDbvItemViaWebClient()
        {
            // get specific version
            var url = "dbv://rules:2/test%20with%20spaces/dummy.csv";

            var repository = new DbvItemRepository(new DbvItemMemoryStore());

            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("first checkin"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("third checkin"), "Checking", "john doe");

            RepositoryLocator.Repository = repository;

            //WebRequest.RegisterPrefix("dbv", new DbvRequestCreator(RepositoryLocator));


            var wc     = new WebClient();
            var result = wc.DownloadString(url);

            Console.Out.WriteLine("result = {0}", result);
            Assert.AreEqual("HELLO WORLD", result);

            Assert.Contains("X-DBV-Revision", wc.ResponseHeaders.AllKeys);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Revision'] = {0}", wc.ResponseHeaders["X-DBV-Revision"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Comments'] = {0}", wc.ResponseHeaders["X-DBV-Comments"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Name'] = {0}", wc.ResponseHeaders["X-DBV-Name"]);
            Console.Out.WriteLine("wc.ResponseHeaders['X-DBV-Timestamp'] = {0}", wc.ResponseHeaders["X-DBV-Timestamp"]);
            Console.Out.WriteLine("wc.ResponseHeaders['Content-Type'] = {0}", wc.ResponseHeaders["Content-Type"]);


            // NO ASYNC IMPLEMENTATION

            /*
             * var t = wc.DownloadStringTaskAsync(url);
             * Console.Out.WriteLine("t.Result = {0}", t.Result);
             */
        }
Ejemplo n.º 7
0
        public void RegisterWebRequest()
        {
            var url = "dbv://rules/test with space/test.pdf";


            var repository = new DbvItemRepository(new DbvItemMemoryStore());

            repository.Checkin("/test/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");

            repository.Checkin("/test with space/test.pdf", Encoding.ASCII.GetBytes("%PDF-"), "Checkin pdf", "jane doe");

            RepositoryLocator.Repository = repository;



            var r = WebRequest.Create(url);

            Assert.IsInstanceOf <DbvWebRequest>(r);

            // and the response
            var resp = r.GetResponse();

            Assert.IsInstanceOf <DbvWebResponse>(resp);

            Console.Out.WriteLine(resp.ContentLength);

            var data = new byte[resp.ContentLength];

            resp.GetResponseStream().Read(data, 0, (int)resp.ContentLength);

            var result = Encoding.UTF8.GetString(data);

            Console.Out.WriteLine("result = {0}", result);
            Console.Out.WriteLine("resp.ContentType = {0}", resp.ContentType);
            //Assert.AreEqual("HELLO WORLD", result);
        }
Ejemplo n.º 8
0
        public void FillTestRepository(DbvItemRepository repository)
        {
            var content = Encoding.ASCII.GetBytes("Hello World");

            repository.Checkin("/test/dummy.csv", content, "CheckinComments", "John Doe");
            repository.Checkin("/second/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/second/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
        }
        public void FillTestRepository(DbvItemRepository repository)
        {
            var content = Encoding.ASCII.GetBytes("Hello World");

            repository.Checkin("/test/dummy.csv", content, "CheckinComments", "John Doe");
            repository.Checkin("/second/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/second/dummy.csv", content, "Checkin Comments", "John Doe");
            repository.Checkin("/test/dummy.csv", content, "Checkin Comments", "John Doe");
        }
Ejemplo n.º 10
0
        public void RegisterWebRequest()
        {
            var url = "dbv://rules/test with space/test.pdf";

            var repository = new DbvItemRepository(new DbvItemMemoryStore());
            repository.Checkin("/test/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");

            repository.Checkin("/test with space/test.pdf", Encoding.ASCII.GetBytes("%PDF-"), "Checkin pdf", "jane doe");

            RepositoryLocator.Repository = repository;

            var r = WebRequest.Create(url);

            Assert.IsInstanceOf<DbvWebRequest>(r);

            // and the response
            var resp = r.GetResponse();
            Assert.IsInstanceOf<DbvWebResponse>(resp);

            Console.Out.WriteLine(resp.ContentLength);

            var data = new byte[resp.ContentLength];
            resp.GetResponseStream().Read(data, 0, (int) resp.ContentLength);

            var result = Encoding.UTF8.GetString(data);

            Console.Out.WriteLine("result = {0}", result);
            Console.Out.WriteLine("resp.ContentType = {0}", resp.ContentType);
            //Assert.AreEqual("HELLO WORLD", result);
        }
Ejemplo n.º 11
0
        public void GetDbvItemViaWebClientUnknownItem()
        {
            // get specific version
            var url = "dbv://rules:2/test/dummy.csv";

            var repository = new DbvItemRepository(new DbvItemMemoryStore());
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("first checkin"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("HELLO WORLD"), "Checking", "john doe");
            repository.Checkin("/test with spaces/dummy.csv", Encoding.UTF8.GetBytes("third checkin"), "Checking", "john doe");

            RepositoryLocator.Repository = repository;

            //WebRequest.RegisterPrefix("dbv", new DbvRequestCreator(RepositoryLocator));

            var wc = new WebClient();
            var result = wc.DownloadString(url);
        }
Ejemplo n.º 12
0
        public void CheckinOneElementInDatabase()
        {
            var rev = _repo.Checkin("/test/dummy.csv", Encoding.ASCII.GetBytes("ABCDEFG"), "Checkin comment", "john doe");

            Assert.AreEqual(1, rev);

            var results = _connection.Query <DbvItem>("select * from DBV_REVISION_STORE").ToList();

            Assert.IsNotEmpty(results);
            var r = results.First();

            Assert.AreEqual("/test/dummy.csv", r.Name);
        }