Example #1
0
        protected override ICollection <IUnitTestElement> GetUnitTestElements(IProject testProject, string assemblyLocation)
        {
            var elements = base.GetUnitTestElements(testProject, assemblyLocation).ToList();
            var element  = elements.Single(e => e.ShortName == "HasRunWith") as XunitTestClassElement;

            var services = testProject.GetComponent <XunitServiceProvider>();
            var unitTestElementFactory = new UnitTestElementFactory(services, null);
            var theoryElement          = unitTestElementFactory.GetOrCreateTestMethod(testProject,
                                                                                      element, element.TypeName, "TestMethodWithExistingTask",
                                                                                      string.Empty, new OneToSetMap <string, string>(), isDynamic: true);

            elements.Add(theoryElement);
            return(elements);
        }
        private IUnitTestElement ProcessTestMethod(IMethod testMethod)
        {
            var project   = psiFile.GetProject();
            var testClass = testMethod.GetContainingType() as IClass;

            if (!conventionCheck.IsValidTestMethod(project, testClass, testMethod))
            {
                return(null);
            }

            var isDynamic = conventionCheck.IsParameterizedMethod(project, testClass, testMethod);

            var clrTypeName  = testClass.GetClrName();
            var assemblyPath = project.GetOutputFilePath().FullPath;

            return(unitTestElementFactory.GetOrCreateTestMethod(project, clrTypeName, testMethod.ShortName, assemblyPath, isDynamic));
        }
        internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory)
        {
            var testClass = parentElement as TestClassElement;

            if (testClass == null)
            {
                throw new InvalidOperationException("parentElement should be Fixie test class");
            }

            var typeName        = parent.GetAttribute(AttributeNames.TypeName);
            var methodName      = parent.GetAttribute(AttributeNames.MethodName);
            var projectId       = parent.GetAttribute(AttributeNames.ProjectId);
            var isParameterized = bool.Parse(parent.GetAttribute(AttributeNames.IsParameterized));

            var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId);

            if (project == null)
            {
                return(null);
            }

            return(unitTestElementFactory.GetOrCreateTestMethod(project, testClass,
                                                                typeName, methodName, isParameterized));
        }
        internal static IUnitTestElement ReadFromXml(XmlElement parent, IUnitTestElement parentElement, ISolution solution, UnitTestElementFactory unitTestElementFactory)
        {
            var testClass = parentElement as TestClassElement;
            if (testClass == null)
                throw new InvalidOperationException("parentElement should be Fixie test class");

            var typeName = parent.GetAttribute(AttributeNames.TypeName);
            var methodName = parent.GetAttribute(AttributeNames.MethodName);
            var projectId = parent.GetAttribute(AttributeNames.ProjectId);
            var isParameterized = bool.Parse(parent.GetAttribute(AttributeNames.IsParameterized));

            var project = (IProject)ProjectUtil.FindProjectElementByPersistentID(solution, projectId);
            if (project == null)
                return null;

            return unitTestElementFactory.GetOrCreateTestMethod(project, testClass,
                typeName, methodName, isParameterized);
        }