Esempio n. 1
0
 protected ParameterizedTestHost(string name, TypeInfo type,
                                 IParameterSerializer serializer, TestFlags flags = TestFlags.None)
     : base(name, name, TestSerializer.GetFriendlyName(type.AsType()), flags)
 {
     ParameterName     = name;
     ParameterTypeInfo = type;
     Serializer        = serializer;
 }
Esempio n. 2
0
        public bool ParameterMatches <T> (string name = null)
        {
            if (!IsParameterized)
            {
                return(false);
            }

            if (name != null)
            {
                return(Host.Identifier.Equals(name));
            }
            else
            {
                var friendlyName = TestSerializer.GetFriendlyName(typeof(T));
                return(friendlyName.Equals(Host.ParameterType));
            }
        }
Esempio n. 3
0
        public static XElement WriteStatisticsEvent(TestLoggerBackend.StatisticsEventArgs instance)
        {
            if (instance.IsRemote)
            {
                throw new InternalErrorException();
            }

            var element = new XElement("TestStatisticsEventArgs");

            element.SetAttributeValue("Type", instance.Type.ToString());
            element.SetAttributeValue("Status", instance.Status.ToString());

            if (instance.Name != null)
            {
                element.Add(TestSerializer.WriteTestName(instance.Name));
            }

            return(element);
        }
Esempio n. 4
0
        public static XElement WriteTestResult(TestResult instance)
        {
            var element = new XElement("TestResult");

            element.SetAttributeValue("Status", instance.Status.ToString());

            element.Add(TestSerializer.WriteTestName(instance.Name));

            if (instance.Path != null)
            {
                element.Add(instance.Path.SerializePath());
            }

            foreach (var error in instance.Errors)
            {
                element.Add(WriteError(error));
            }

            if (instance.HasMessages)
            {
                foreach (var message in instance.Messages)
                {
                    var msgElement = new XElement("Message");
                    msgElement.SetAttributeValue("Text", message);
                    element.Add(msgElement);
                }
            }

            if (instance.HasLogEntries)
            {
                foreach (var entry in instance.LogEntries)
                {
                    element.Add(WriteLogEntry(entry));
                }
            }

            foreach (var child in instance.Children)
            {
                element.Add(WriteTestResult(child));
            }

            return(element);
        }
Esempio n. 5
0
        public static TestResult ReadTestResult(XElement node)
        {
            if (!node.Name.LocalName.Equals("TestResult"))
            {
                throw new InternalErrorException();
            }

            var name   = TestSerializer.ReadTestName(node.Element("TestName"));
            var status = (TestStatus)Enum.Parse(typeof(TestStatus), node.Attribute("Status").Value);

            var result = new TestResult(name, status);

            var path = node.Element("TestPath");

            if (path != null)
            {
                result.Path = new PathWrapper(path);
            }

            foreach (var error in node.Elements("Error"))
            {
                result.AddError(ReadError(error));
            }

            foreach (var message in node.Elements("Message"))
            {
                result.AddMessage(message.Attribute("Text").Value);
            }

            foreach (var log in node.Elements("LogEntry"))
            {
                result.AddLogMessage(ReadLogEntry(log));
            }

            foreach (var child in node.Elements("TestResult"))
            {
                result.AddChild(ReadTestResult(child));
            }

            return(result);
        }
Esempio n. 6
0
        public static TestLoggerBackend.StatisticsEventArgs ReadStatisticsEvent(XElement node)
        {
            if (!node.Name.LocalName.Equals("TestStatisticsEventArgs"))
            {
                throw new InternalErrorException();
            }

            var instance = new TestLoggerBackend.StatisticsEventArgs();

            instance.Type     = (TestLoggerBackend.StatisticsEventType)Enum.Parse(typeof(TestLoggerBackend.StatisticsEventType), node.Attribute("Type").Value);
            instance.Status   = (TestStatus)Enum.Parse(typeof(TestStatus), node.Attribute("Status").Value);
            instance.IsRemote = true;

            var name = node.Element("TestName");

            if (name != null)
            {
                instance.Name = TestSerializer.ReadTestName(name);
            }

            return(instance);
        }
Esempio n. 7
0
 public XElement SerializePath()
 {
     return(TestSerializer.SerializePath(this));
 }
Esempio n. 8
0
 public HeavyTestHost(string identifier, string name, Type type, Type hostType, TestFlags flags)
     : base(identifier, name, TestSerializer.GetFriendlyName(hostType), flags)
 {
     Type = type;
 }