using System.Reflection;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moonlit.Reflection;
 
namespace Moonlit.TestFixtures
{


    /// <summary>
    ///ÕâÊÇ AssemblyDescriptor_Test µÄ²âÊÔÀà£¬Ö¼ÔÚ
    ///°üº¬ËùÓÐ AssemblyDescriptor_Test µ¥Ôª²âÊÔ
    ///</summary>
    [TestClass()]
    public class AssemblyDescriptorTests
    {


        private TestContext testContextInstance;

        /// <summary>
        ///»ñÈ¡»òÉèÖÃ²âÊÔÉÏÏÂÎÄ£¬ÉÏÏÂÎÄÌá¹©
        ///ÓÐ¹Øµ±Ç°²âÊÔÔËÐÐ¼°Æä¹¦ÄÜµÄÐÅÏ¢¡£
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region ¸½¼Ó²âÊÔÊôÐÔ
        // 
        //±àÐ´²âÊÔÊ±£¬»¹¿ÉÊ¹ÓÃÒÔÏÂÊôÐÔ:
        //
        //Ê¹ÓÃ ClassInitialize ÔÚÔËÐÐÀàÖÐµÄµÚÒ»¸ö²âÊÔÇ°ÏÈÔËÐÐ´úÂë
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Ê¹ÓÃ ClassCleanup ÔÚÔËÐÐÍêÀàÖÐµÄËùÓÐ²âÊÔºóÔÙÔËÐÐ´úÂë
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Ê¹ÓÃ TestInitialize ÔÚÔËÐÐÃ¿¸ö²âÊÔÇ°ÏÈÔËÐÐ´úÂë
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Ê¹ÓÃ TestCleanup ÔÚÔËÐÐÍêÃ¿¸ö²âÊÔºóÔËÐÐ´úÂë
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///GetPath µÄ²âÊÔ
        ///</summary>
        [TestMethod()]
        public void GetPath_Test()
        {
            Assembly assembly = typeof(AssemblyDescriptorTests).Assembly;
            string assemblyPath = assembly.Location;

            Assert.IsTrue(File.Exists(assemblyPath));

            var assembly1 = AssemblyExtension.SafeLoadFile(assemblyPath);

            Assert.AreNotSame(assembly, assembly1);
            var type = assembly1.GetType("Moonlit.TestFixtures.AssemblyDescriptor_Test");
            Assert.IsNotNull(type);
        }
    }
}
