SetDescription() public method

Sets the description for the test case being constructed.
public SetDescription ( string description ) : TestCaseData
description string The description.
return TestCaseData
        public static IEnumerable<TestCaseData> ExtractMethodTestFactoryMethod()
        {
            string[] files = Directory.GetFiles(@"..\..\Ralph.Core.Tests\ExtractMethodTests\TestCases", "*.cs");
            foreach (var file in files)
            {
                string codefile = Path.GetFullPath(file);
                string codeText = File.ReadAllText(codefile);

                var testCaseData = new TestCaseData(codeText);
                testCaseData.SetName(Path.GetFileNameWithoutExtension(codefile));
                testCaseData.SetDescription(ParseDesc(codeText));

                yield return testCaseData;
            }
        }
 public IEnumerable<TestCaseData> TestCases()
 {
     var namespaceLength = typeof(Harness).Namespace.Length + 1;
     var assembly = Assembly.GetExecutingAssembly();
     var resourceNames = assembly.GetManifestResourceNames().Where(name => name.EndsWith(Extension));
     foreach(var resourceName in resourceNames)
     {
         var stream = assembly.GetManifestResourceStream(resourceName);
         var reader = new StreamReader(stream);
         var config = TestCaseConfig.Read(reader);
         config.FileName = resourceName;
         config.TestName = resourceName.Substring(namespaceLength, resourceName.Length - namespaceLength - Extension.Length);
         var testCaseData = new TestCaseData(config, reader).SetName(config.TestName);
         if(!string.IsNullOrWhiteSpace(config.Description))
             testCaseData.SetDescription(config.Description);
         yield return testCaseData;
     }
 }
Esempio n. 3
0
 private static TestCaseData MapTestCaseData(NPQTest qUnitTest)
 {
     var testCase = new TestCaseData(qUnitTest);
     testCase.SetName(qUnitTest.Name);
     testCase.SetDescription(qUnitTest.Description);
     return testCase;
 }
Esempio n. 4
0
        private IEnumerable<TestCaseData> BuildTestCases(IEnumerable<TestXml> tests)
        {
            var testCases = new List<TestCaseData>(tests.Count());

            foreach (var test in tests)
            {
                TestCaseData testCaseDataNUnit = new TestCaseData(test);
                testCaseDataNUnit.SetName(test.GetName());
                testCaseDataNUnit.SetDescription(test.Description);
                foreach (var category in test.Categories)
                    testCaseDataNUnit.SetCategory(CategoryHelper.Format(category));
                foreach (var property in test.Traits)
                    testCaseDataNUnit.SetProperty(property.Name, property.Value);

                //Assign auto-categories
                if (EnableAutoCategories)
                {
                    foreach (var system in test.Systems)
                        foreach (var category in system.GetAutoCategories())
                            testCaseDataNUnit.SetCategory(CategoryHelper.Format(category));
                }
                //Assign auto-categories
                if (EnableGroupAsCategory)
                {
                    foreach (var groupName in test.GroupNames)
                        testCaseDataNUnit.SetCategory(CategoryHelper.Format(groupName));
                }

                testCases.Add(testCaseDataNUnit);
            }
            return testCases;
        }
Esempio n. 5
0
    public IEnumerable GetObservations()
    {
      var t = GetType();

      var categoryName = "Uncategorized";
      var description = string.Empty;

#if NET_STANDARD
      var categoryAttributes = t.GetTypeInfo().CustomAttributes.Where(ca => ca.AttributeType == typeof(CategoryAttribute));
      var subjectAttributes = t.GetTypeInfo().CustomAttributes.Where(ca => ca.AttributeType == typeof(SubjectAttribute));
#else
      var categoryAttributes = t.GetCustomAttributes(typeof(CategoryAttribute), true);
      var subjectAttributes = t.GetCustomAttributes(typeof(SubjectAttribute), true);
#endif

#if NET_STANDARD
            if (categoryAttributes.Any())
      {
        categoryName = categoryAttributes.First().ConstructorArguments[0].Value.ToString();
#else
      if (categoryAttributes.Length > 0)
      {
        var categoryAttribute = (CategoryAttribute)categoryAttributes[0];
        categoryName = categoryAttribute.Name;
#endif
      }

#if NET_STANDARD
      if (subjectAttributes.Any())
      {
        description = subjectAttributes.First().ConstructorArguments[0].Value.ToString();
#else
            if (subjectAttributes.Length > 0)
      {
        var subjectAttribute = (SubjectAttribute)subjectAttributes[0];
        description = subjectAttribute.Subject;
#endif
      }

      var fieldInfos = t.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
      var itFieldInfos = new List<FieldInfo>();

      foreach (var info in fieldInfos)
      {
        if (info.FieldType.Name.Equals("It"))
          itFieldInfos.Add(info);
      }

      foreach (var it in itFieldInfos)
      {
        var data = new TestCaseData(it.GetValue(this));
        data.SetDescription(description);
        data.SetName(it.Name.Replace("_", " "));
        data.SetCategory(categoryName);
        yield return data;
      }
    }

    [Test, SpecificationSource("GetObservations")]
        protected static IEnumerable<TestCaseData> ConvertCodeFileToTestCaseData(string[] files, MethodsOnASingleClassCloneFinder clonefinder)
        {
            foreach (var file in files)
            {
                var codefile = Path.GetFullPath(file);
                var codeText = File.ReadAllText(codefile);
                var tcase = new TestCaseData(codefile, clonefinder);

                var desc = string.Join(" ", (from str11 in codeText.Split(Environment.NewLine.ToCharArray())
                                             where str11.TrimStart().StartsWith("//")
                                             select str11.Trim().TrimStart('/')).ToArray()).Trim();
                tcase.SetDescription(desc);
                tcase.SetName(Path.GetFileNameWithoutExtension(file));

                if(desc.StartsWith("Ignore"))
                    tcase.Ignore(desc);

                yield return tcase;
            }
        }