Exemple #1
0
        public void CanMakeTestCaseShouldBuildTraitsCache()
        {
            var xmlNodeList = FakeTestData.GetTestNodes();

            foreach (XmlNode node in xmlNodeList)
            {
                var testCase = testConverter.ConvertTestCase(new NUnitTestCase(node));
            }

            var traitsCache = testConverter.TraitsCache;

            // There are 12 ids in the TestXml2, but will be storing only ancestor properties.
            // Not the leaf node test-case properties.
            Assert.That(traitsCache.Keys.Count, Is.EqualTo(7));

            // Even though ancestor doesn't have any properties. Will be storing their ids.
            // So that we will not make call SelectNodes call again.
            CheckNodesWithNoProperties(traitsCache);

            // Will not be storing leaf nodes test-case nodes in the cache.
            CheckNoTestCaseNodesExist(traitsCache);

            // Checking assembly level attribute.
            CheckNodeProperties(traitsCache, "0-1009", new[] { new KeyValuePair <string, string>("Category", "AsmCat") });

            // Checking Class level attributes base class & dervied class
            CheckNodeProperties(traitsCache, "0-1000", new[] { new KeyValuePair <string, string>("Category", "BaseClass") });
            CheckNodeProperties(traitsCache, "0-1002", new[] { new KeyValuePair <string, string>("Category", "DerivedClass"), new KeyValuePair <string, string>("Category", "BaseClass") });

            // Checking Nested class attributes.
            CheckNodeProperties(traitsCache, "0-1005", new[] { new KeyValuePair <string, string>("Category", "NS1") });
            CheckNodeProperties(traitsCache, "0-1007", new[] { new KeyValuePair <string, string>("Category", "NS2") });
        }
        public void CanMakeTestCaseShouldBuildTraitsCache()
        {
            var xmlNodeList = FakeTestData.GetTestNodes();
            var tf          = Substitute.For <INUnitDiscoveryCanHaveTestCases>();

            foreach (XmlNode node in xmlNodeList)
            {
                var xElem    = XElement.Load(node.CreateNavigator().ReadSubtree());
                var tc       = DiscoveryConverter.ExtractTestCase(tf, xElem);
                var testCase = testConverter.ConvertTestCase(tc);
            }

            var traitsCache = testConverter.TraitsCache;

            Assert.Multiple(() =>
            {
                // There are 12 ids in the TestXml2, but will be storing only ancestor properties.
                // Not the leaf node test-case properties.
                Assert.That(traitsCache.Keys.Count, Is.EqualTo(7));

                // Even though ancestor doesn't have any properties. Will be storing their ids.
                // So that we will not make call SelectNodes call again.
                CheckNodesWithNoProperties(traitsCache);

                // Will not be storing leaf nodes test-case nodes in the cache.
                CheckNoTestCaseNodesExist(traitsCache);

                // Checking assembly level attribute.
                CheckNodeProperties(traitsCache, "0-1009",
                                    new[] { new KeyValuePair <string, string>("Category", "AsmCat") });

                // Checking Class level attributes base class & dervied class
                CheckNodeProperties(traitsCache, "0-1000",
                                    new[] { new KeyValuePair <string, string>("Category", "BaseClass") });
                CheckNodeProperties(traitsCache, "0-1002",
                                    new[]
                {
                    new KeyValuePair <string, string>("Category", "DerivedClass"),
                    new KeyValuePair <string, string>("Category", "BaseClass")
                });

                // Checking Nested class attributes.
                CheckNodeProperties(traitsCache, "0-1005", new[] { new KeyValuePair <string, string>("Category", "NS1") });
                CheckNodeProperties(traitsCache, "0-1007", new[] { new KeyValuePair <string, string>("Category", "NS2") });
            });
        }