Example #1
0
 public void ResetTest(string path1, string path2)
 {
     using (Curl curl = new Curl())
     {
         curl.UseBom = true;
         string s1 = curl.GetString(new Uri(Path.GetFullPath(path1)).AbsoluteUri);
         Output.WriteLine(s1);
         Assert.Equal(File.ReadAllText(path1), s1);
         curl.Reset();
         string s2 = curl.GetString(new Uri(Path.GetFullPath(path2)).AbsoluteUri);
         Output.WriteLine(s2);
         Assert.Equal(File.ReadAllText(path2), s2);
     }
 }
Example #2
0
 public void BomTest(string path)
 {
     using (Curl curl = new Curl())
     {
         curl.UseBom = true;
         string s = curl.GetString(new Uri(Path.GetFullPath(path)).AbsoluteUri);
         Output.WriteLine(s);
         Assert.Equal(File.ReadAllText(path), s);
     }
 }
Example #3
0
        public void Utf8Test(string path)
        {
            UTF8Encoding encoding = new UTF8Encoding(false, true);

            using (Curl curl = new Curl())
            {
                string s = curl.GetString(new Uri(Path.GetFullPath(path)).AbsoluteUri, encoding);
                Output.WriteLine(s);
                Assert.Equal(File.ReadAllText(path, encoding), s);
            }
        }
Example #4
0
        public void InvalidEncodingTest(string path)
        {
            UTF8Encoding encoding = new UTF8Encoding(false, true);

            Assert.Throws <DecoderFallbackException>(() =>
            {
                using (Curl curl = new Curl())
                {
                    curl.GetString(new Uri(Path.GetFullPath(path)).AbsoluteUri, encoding);
                }
            });
        }
Example #5
0
        public void ProgressEventTest(string path)
        {
            UTF8Encoding encoding = new UTF8Encoding(false, true);

            using (Curl curl = new Curl())
            {
                curl.UseBom = true;
                int progress = 0;

                void OnCurlOnDownloadProgressChange(Curl sender, Curl.Progress curprogress)
                {
                    Output.WriteLine(curprogress.ToString());
                    // ReSharper disable HeapView.BoxingAllocation
                    Assert.True(progress < curprogress.Done, $"{progress} >= {curprogress.Done}");
                    // ReSharper restore HeapView.BoxingAllocation
                    progress = curprogress.Done;
                }

                curl.DownloadProgressChange += OnCurlOnDownloadProgressChange;
                Assert.Equal(File.ReadAllText(path, encoding), curl.GetString(new Uri(Path.GetFullPath(path)).AbsoluteUri, encoding));
                Assert.NotEqual(0, progress);
            }
        }