示例#1
0
 public Tests(IORMToolServices services)
 {
     // Cache the services for future use
     myServices = services;
     // The services from the test tool can be retrieved
     // from the code services service provider.
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#2
0
文件: Tests.cs 项目: cjheath/NORMA
		public Tests(IORMToolServices services)
		{
			// Cache the services for future use
			myServices = services;
			// The services from the test tool can be retrieved
			// from the code services service provider.
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
示例#3
0
		public PreferredPathTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
 public FCExactlyOneTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#5
0
 public ConstraintContradictionTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#6
0
 public DTBlankTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#7
0
		public ImplicationErrorTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
示例#8
0
 /// <summary>
 /// Create a new UISafeEventManager
 /// </summary>
 public ModelingEventManagerImpl(Store store, IORMToolTestServices testServices)
     : base(store)
 {
     myTestServices = testServices;
 }
示例#9
0
		public PopulationTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
示例#10
0
 public PopulationTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#11
0
		public FCMinMaxTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
 public PreferredPathTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#13
0
        /// <summary>
        /// Run all tests for the given type that match the
        /// category filters specified for this suite
        /// </summary>
        /// <param name="testType">A type with a Test attribute</param>
        /// <param name="services">Services used to run the test. IORMToolTestServices can
        /// be retrieved from services.ServiceProvider.</param>
        /// <param name="suiteReport">The suite report callback</param>
        private void RunTests(Type testType, IORMToolServices services, IORMToolTestSuiteReport suiteReport)
        {
            IORMToolTestServices testServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
            object testTypeInstance           = null;

            object[]     methodParams = null;
            MethodInfo[] methods      = testType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            int          methodCount  = methods.Length;

            for (int i = 0; i < methodCount; ++i)
            {
                MethodInfo method         = methods[i];
                object[]   testAttributes = method.GetCustomAttributes(typeof(ORMTestAttribute), false);
                Debug.Assert(testAttributes.Length < 2, "Single use attribute with inherit=false, should only pick up zero or one attributes");
                // Make sure that the method is flagged as a Test method that can be run per the current category settings
                if (testAttributes.Length == 0 || !CheckCategoryFilters((ORMTestAttribute)testAttributes[0]))
                {
                    continue;
                }

                // Make sure we've instantiated the test class
                if (testTypeInstance == null)
                {
                    ConstructorInfo constructor;
                    if (null != (constructor = testType.GetConstructor(new Type[] { typeof(IORMToolServices) })))
                    {
                        testTypeInstance = constructor.Invoke(new object[] { services });
                        methodParams     = new object[1];
                    }
                    bool loadFailure = null == testTypeInstance;
                    suiteReport.BeginTestClass(testType.Namespace, testType.Name, loadFailure);
                    if (loadFailure)
                    {
                        return;
                    }
                }

                ParameterInfo[] methodParamInfos = method.GetParameters();
                if (!(methodParamInfos.Length == 1 && typeof(Store).IsAssignableFrom(methodParamInfos[0].ParameterType)))
                {
                    // The test method does not match the signature we need, it should
                    // not have been marked with the Test attribute
                    suiteReport.ReportTestResults(method.Name, ORMTestResult.FailBind, null);
                }
                else
                {
                    Store store = null;
                    try
                    {
                        // Prepare the test services for a new test
                        testServices.OpenReport();

                        // Populate a store. Automatically loads the starting
                        // file from the test assembly if one is provided
                        store = testServices.Load(method, null, null);

                        // Run the method
                        methodParams[0] = store;
                        method.Invoke(testTypeInstance, methodParams);

                        // Compare the current contents of the store with the
                        // expected state
                        testServices.Compare(store, method, null);
                        testServices.LogValidationErrors(null);
                    }
                    finally
                    {
                        if (store != null)
                        {
                            ((IDisposable)store).Dispose();
                        }

                        // Close the report and see if the report matches the expected results
                        using (XmlReader reportReader = testServices.CloseReport(method))
                        {
                            string methodName     = method.Name;
                            string resourceName   = string.Concat(testType.FullName, ".", methodName, ".Report.xml");
                            Stream baselineStream = null;
                            try
                            {
                                Assembly testAssembly = testType.Assembly;
                                // Get the baseline that we're comparing to
                                if (null != testAssembly.GetManifestResourceInfo(resourceName))
                                {
                                    baselineStream = testAssembly.GetManifestResourceStream(resourceName);
                                }
                                if (baselineStream != null)
                                {
                                    bool hasDiff = false;

                                    // See if the data is different.
                                    XmlDiff           diff           = DiffEngine;
                                    XmlReaderSettings readerSettings = DetachableReaderSettings;
                                    XmlWriterSettings writerSettings = DetachableWriterSettings;
                                    using (MemoryStream diffStream = new MemoryStream())
                                    {
                                        using (XmlReader baselineReader = XmlReader.Create(baselineStream, readerSettings))
                                        {
                                            using (XmlWriter diffWriter = XmlWriter.Create(diffStream, writerSettings))
                                            {
                                                hasDiff = !diff.Compare(baselineReader, reportReader, diffWriter);
                                            }
                                        }
                                        if (hasDiff)
                                        {
                                            // Record the diffgram in the suite report
                                            diffStream.Seek(0, SeekOrigin.Begin);
                                            using (XmlReader diffReader = XmlTextReader.Create(diffStream, readerSettings))
                                            {
                                                suiteReport.ReportTestResults(methodName, ORMTestResult.FailReportDiffgram, diffReader);
                                            }
                                        }
                                        else
                                        {
                                            // Record a passing result
                                            suiteReport.ReportTestResults(methodName, ORMTestResult.Pass, null);
                                        }
                                    }
                                }
                                else
                                {
                                    // Record the full report, we have no baseline to compare against
                                    suiteReport.ReportTestResults(methodName, ORMTestResult.FailReportBaseline, reportReader);
                                }
                            }
                            finally
                            {
                                if (baselineStream != null)
                                {
                                    ((IDisposable)baselineStream).Dispose();
                                }
                            }
                        }
                    }
                }
            }
        }
		public ConstraintContradictionTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
示例#15
0
 public ImplicationErrorTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }
示例#16
0
		public FCExactlyOneTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
示例#17
0
		public NotWellModeledTests(IORMToolServices services)
		{
			myServices = services;
			myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
		}
 public NotWellModeledTests(IORMToolServices services)
 {
     myServices     = services;
     myTestServices = (IORMToolTestServices)services.ServiceProvider.GetService(typeof(IORMToolTestServices));
 }