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);
            */
        }
示例#2
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");
        }
        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);
        }
示例#5
0
        public void VerifyTestDatabaseExists()
        {
            _connectionFactory = new ConnectionFactory(ConfigurationManager.ConnectionStrings["DBV_TEST"].ConnectionString);
            _connection        = _connectionFactory.GetConnection();
            _connection.Open();
            Assert.AreEqual(ConnectionState.Open, _connection.State);
            // verify table exists
            _connection.Close();

            _repo = new DbvItemRepository(new DbvItemSqlServerStore(_connectionFactory, "DBV_REVISION_STORE"));
        }
示例#6
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);
        }
        public DbvWebRequest(DbvItemRepository repository, Uri url)
            : base()
        {
            // do whatever initialization is required here
            if (url.Scheme != "dbv") // This class is only for ftp urls
            {
                throw new NotSupportedException("This protocol is not supported");
            }

            _requestUri = url;
            _repository = repository;
            _method     = "checkout"; // default is to retrieve a file
        }
        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);
        }
        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 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);
        }
示例#11
0
 public void Setup()
 {
     Repository = new DbvItemRepository(new DbvItemMemoryStore());
     FillTestRepository(Repository);
 }
 public void Setup()
 {
     Repository = new DbvItemRepository(new DbvItemMemoryStore());
     FillTestRepository(Repository);
 }
        public DbvWebRequest(DbvItemRepository repository, Uri url)
            : base()
        {
            // do whatever initialization is required here
            if (url.Scheme != "dbv") // This class is only for ftp urls
                throw new NotSupportedException("This protocol is not supported");

            _requestUri = url;
            _repository = repository;
            _method = "checkout"; // default is to retrieve a file
        }
        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);
        }
        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);
        }
        public void VerifyTestDatabaseExists()
        {
            _connectionFactory = new ConnectionFactory(ConfigurationManager.ConnectionStrings["DBV_TEST"].ConnectionString);
            _connection = _connectionFactory.GetConnection();
            _connection.Open();
            Assert.AreEqual(ConnectionState.Open, _connection.State);
            // verify table exists
            _connection.Close();

            _repo = new DbvItemRepository(new DbvItemSqlServerStore(_connectionFactory, "DBV_REVISION_STORE"));
        }