Exemplo n.º 1
0
        public override void Execute(IAssert assert)
        {
            var data = SetUp();
            var typesToTest = GetTypesToTest(data);
            if (typesToTest.Length == 0)
            {
                assert.Inconclusive(
                    "No types found to apply the convention to. Make sure the Types predicate is correct and that the right assemblies to scan are specified.");
            }
            var invalidItems = Array.FindAll(typesToTest, t => data.Must(t) == false);

            var message = new StringBuilder();
            message.AppendLine(data.Description ?? "Invalid types found");
            foreach (var invalidType in invalidItems)
            {
                message.Append('\t');
                data.ItemDescription(invalidType, message);
            }
            if (data.HasApprovedExceptions)
            {
                Approve(message.ToString());
            }
            else
            {
                assert.AreEqual(0, invalidItems.Count(), message.ToString());
            }
        }