Exemplo n.º 1
0
        public TestAgent(Type containerType, TestContainerAttribute attribute, WarningHandler warningHandler)
        {
            ContainerType = containerType;
            MilestoneCount = attribute.MilestoneCount;
            IterationCount = attribute.IterationCount;
            Mode = attribute.Mode;
            Label = attribute.Label;
            Metrics = attribute.Metrics;
            Id = attribute.Id;
            TestedType = attribute.TestedType;

            _warningHandler = warningHandler;
        }
Exemplo n.º 2
0
        private List<TestAgent> FillTestAgentsWithTested(Type t, TestContainerAttribute tcAttribute, List<String> testedAssemblyNames)
        {
            var prototype = FillTestAgent(t, tcAttribute);
            var agents = new List<TestAgent>();

            if (!prototype.IsValid)
            {
                return agents;
            }

            var testedType = tcAttribute.TestedType;
            foreach (var testedAssemblyName in testedAssemblyNames)
            {
                var testedAssembly = Assembly.Load(testedAssemblyName);

                //todo: test it! check if has ctor() ?
                //todo: investigate the possibility to test generic types
                var types = testedAssembly.GetExportedTypes().Where(e =>
                    testedType.IsAssignableFrom(e) && e.IsClass && !e.IsAbstract && !e.IsGenericType);
                foreach (var type in types)
                {
                    var agent = prototype.Clone();
                    agent.TestedType = type;
                    agents.Add(agent);
                }
            }

            if (agents.Count == 0)
            {
                _warningHandler.NoAppropriateTestedTypesWereFoundWarning(t, tcAttribute);
            }

            return agents;
        }
Exemplo n.º 3
0
        private TestAgent FillTestAgent(Type t, TestContainerAttribute tcAttribute)
        {
            var agent = new TestAgent(t, tcAttribute, _warningHandler);

            var allMethods = t.GetMethods();
            foreach (var method in allMethods)
            {
                agent.AddMethodIfMatches(method);
            }
            agent.CompleteFilling();

            return agent.IsValid ? agent : null;
        }
Exemplo n.º 4
0
 public void NoTestedAssembliesSpecifiedWarning(Type t, TestContainerAttribute attribute)
 {
     var message = String.Format("Test container {0} refers the tasted type {1}, but no tested assemblies was specified in command line parameteres.", t.ToString(), attribute.TestedType.ToString());
     _warnings.Add(message);
 }
Exemplo n.º 5
0
 public void NoAppropriateTestedTypesWereFoundWarning(Type t, TestContainerAttribute attribute)
 {
     var message = String.Format("No appropriate tested types {0} were found for TestContainer {1}.", attribute.TestedType.ToString(), t.ToString());
     _warnings.Add(message);
 }