public void Constructor_Encoded_Data()
        {
            vCardPhoto p = new vCardPhoto(TestPhotoUrl);

            p.Fetch();
            var bytes = p.GetBytes();

            var base64Image = Convert.ToBase64String(bytes);

            vCardPhoto photo = new vCardPhoto(base64Image, true);

            Assert.IsTrue(photo.HasEncodedData, "encoded data is false");

            var data = photo.EncodedData;

            Assert.AreEqual(base64Image, data);
        }
Esempio n. 2
0
        public void Fetch_Good()
        {
            // You may wish to ignore this test if you run
            // extensive unit tests and your Internet connection
            // is slow.

            vCardPhoto photo = new vCardPhoto(TestPhotoUrl);

            Assert.IsFalse(
                photo.IsLoaded,
                "The photo has not been loaded yet.");

            photo.Fetch();

            Assert.IsTrue(
                photo.IsLoaded,
                "The photo should have been loaded.");

            // Get the bytes of the image.

            byte[] data = photo.GetBytes();

            Assert.AreEqual(
                TestPhotoSize,
                data.Length,
                "The length of the photo is unexpected.");

            #if Linux
            // Throw new NotImplementedException("Not implemented OSX test.");
            #elif OSX
            // Throw new NotImplementedException("Not implemented OSX test.");
            #elif Windows
            using (Bitmap bitmap = photo.GetBitmap())
            {
                Assert.AreEqual(
                    TestPhotoHeight,
                    bitmap.Size.Height,
                    "The photo height is unexpected.");

                Assert.AreEqual(
                    TestPhotoWidth,
                    bitmap.Size.Width,
                    "The photo width is unexpected.");
            }
            #endif
        }