Ejemplo n.º 1
0
        public void TypesCached(string expected, string extension)
        {
            var c = new ContentTypes();

            Assert.AreEqual(expected, c.ContentType(extension));
            Assert.AreEqual(expected, c.ContentType(extension));
            Assert.AreEqual(expected, c.ContentType(extension));
        }
Ejemplo n.º 2
0
        public async Task LoadMD5()
        {
            var c = new ContentTypes();
            var root = Environment.CurrentDirectory;
            var path = string.Format("{0}\\{1}.bin", root, Guid.NewGuid());

            var random = new Random();
            var bytes = new byte[64];
            random.NextBytes(bytes);

            string md5;
            using (var createHash = System.Security.Cryptography.MD5.Create())
            {
                var hash = createHash.ComputeHash(bytes);
                md5 = System.Convert.ToBase64String(hash);
            }

            File.WriteAllBytes(path, bytes);

            var item = new FileItem(root, path);
            await item.LoadMD5();

            Assert.AreEqual(bytes, item.Data);
            Assert.AreEqual(c.ContentType(path), item.ContentType);
            Assert.AreEqual(md5, item.MD5);
        }
Ejemplo n.º 3
0
        public async Task LoadMD5()
        {
            var c    = new ContentTypes();
            var root = Environment.CurrentDirectory;
            var path = string.Format("{0}\\{1}.bin", root, Guid.NewGuid());

            var random = new Random();
            var bytes  = new byte[64];

            random.NextBytes(bytes);

            string md5;

            using (var createHash = System.Security.Cryptography.MD5.Create())
            {
                var hash = createHash.ComputeHash(bytes);
                md5 = System.Convert.ToBase64String(hash);
            }

            File.WriteAllBytes(path, bytes);

            var item = new FileItem(root, path);
            await item.LoadMD5();

            Assert.AreEqual(bytes, item.Data);
            Assert.AreEqual(c.ContentType(path), item.ContentType);
            Assert.AreEqual(md5, item.MD5);
        }
Ejemplo n.º 4
0
        public void ContentTypeFilePathWierd()
        {
            var c = new ContentTypes();

            Assert.That(() => c.ContentType(". "), Throws.TypeOf <InvalidOperationException>());
        }
Ejemplo n.º 5
0
        public void ContentTypeFilePathInvalid()
        {
            var c = new ContentTypes();

            Assert.That(() => c.ContentType(null), Throws.TypeOf <ArgumentException>());
        }