コード例 #1
0
        public void CanStore()
        {
            // Get the folders
            var lookup = MediaFolder.Repository.ToLookUpMulti <string>("Name");
            var file1  = new MediaFile()
            {
                FullNameRaw   = "profile_image.jpg",
                Description   = "Main photo for profile.",
                DirectoryName = "photos",
                SortIndex     = 1,
                IsPublic      = true,
                Length        = 0,
                ParentId      = lookup["photos"].Id,
                Contents      = "testing some sample content".ToBytesAscii()
            };

            var controller = new MediaFileController();

            MediaFile.Create(file1);

            // Confirm 2 things.
            // 1. The length of the MediaFolder is updated.
            // 2. The length of the MediaFile is updated
            // 3. The extension on the MediaFile is set to jpg
            var folder = MediaFolder.Get(lookup["photos"].Id);
            var file   = MediaFile.GetAll()[0];

            Assert.AreEqual(file.Extension, ".jpg");
            Assert.AreEqual(folder.Length, file.Length);
        }