示例#1
0
        public void IsSameOrSubtypeOf_WhenOtherTypeIsASuperType_ReturnsTrue()
        {
            var superSuperType = new FileType("superSuperId", "superSuperDescription", null);
            var superType = new FileType("superId", "superDescription", superSuperType);
            var type = new FileType("id", "description", superType);

            Assert.IsTrue(type.IsSameOrSubtypeOf(superType));
            Assert.IsTrue(type.IsSameOrSubtypeOf(superSuperType));
        }
示例#2
0
        public void IsSameOrSubtypeOf_WhenOtherTypeIsUnrelated_ReturnsFalse()
        {
            var superType = new FileType("superId", "superDescription", null);
            var type = new FileType("id", "description", superType);
            var unrelatedType = new FileType("otherId", "otherDescription", superType);

            Assert.IsFalse(type.IsSameOrSubtypeOf(unrelatedType));
        }
示例#3
0
        public void IsSameOrSubtypeOf_WhenOtherTypeIsNull_Throws()
        {
            var type = new FileType("id", "description", null);

            Assert.Throws<ArgumentNullException>(() => type.IsSameOrSubtypeOf(null));           
        }
示例#4
0
        public void IsSameOrSubtypeOf_WhenOtherTypeIsSame_ReturnsTrue()
        {
            var type = new FileType("id", "description", null);

            Assert.IsTrue(type.IsSameOrSubtypeOf(type));
        }
        /// <summary>
        /// Returns true if the file type is the same or a subtype of one of those specified by <see cref="FileTypes"/>.
        /// </summary>
        /// <param name="fileType">The file type.</param>
        /// <param name="fileTypeManager">The file type manager used to resolve file type ids to file types.</param>
        /// <returns>True if the framework is compatible.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="fileType"/> or <paramref name="fileTypeManager"/> is null.</exception>
        public bool IsFrameworkCompatibleWithFileType(FileType fileType, IFileTypeManager fileTypeManager)
        {
            if (fileType == null)
                throw new ArgumentNullException("fileType");
            if (fileTypeManager == null)
                throw new ArgumentNullException("fileTypeManager");

            foreach (string fileTypeId in FileTypes)
            {
                FileType supportedFileType = fileTypeManager.GetFileTypeById(fileTypeId);
                if (fileType.IsSameOrSubtypeOf(supportedFileType))
                    return true;
            }

            return false;
        }