Ejemplo n.º 1
0
    public void ConstructWithMethodInfoWithProperties()
    {
        Type stubType = typeof(StubClass);
        MethodInfo method = stubType.GetMethod("MethodWithTraits");

        MethodResult result = new TestableMethodResult(Reflector.Wrap(method));

        Assert.Equal(2, result.Traits.Count);
    }
Ejemplo n.º 2
0
        public void ConstructWithMethodInfoWithProperties()
        {
            Type       stubType = typeof(StubClass);
            MethodInfo method   = stubType.GetMethod("MethodWithTraits");

            MethodResult result = new TestableMethodResult(Reflector.Wrap(method));

            Assert.Equal(2, result.Traits.Count);
        }
Ejemplo n.º 3
0
        public void ConstructWithMethodInfo()
        {
            Type       stubType = typeof(StubClass);
            MethodInfo method   = stubType.GetMethod("Method");

            MethodResult result = new TestableMethodResult(Reflector.Wrap(method));

            Assert.Equal("Method", result.MethodName);
            Assert.Equal(typeof(StubClass).FullName, result.TypeName);
            Assert.Equal(0.0, result.ExecutionTime);
            Assert.Equal(0, result.Traits.Count);
        }
Ejemplo n.º 4
0
    public void ToXmlWithDisplayName()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        MethodInfo method = typeof(StubClass).GetMethod("Method");
        TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method), "Display Name");

        XmlNode resultNode = methodResult.ToXml(parentNode);

        Assert.Equal("Display Name", resultNode.Attributes["name"].Value);
    }
Ejemplo n.º 5
0
    public void ConstructWithMethodInfo()
    {
        Type stubType = typeof(StubClass);
        MethodInfo method = stubType.GetMethod("Method");

        MethodResult result = new TestableMethodResult(Reflector.Wrap(method));

        Assert.Equal("Method", result.MethodName);
        Assert.Equal(typeof(StubClass).FullName, result.TypeName);
        Assert.Equal(0.0, result.ExecutionTime);
        Assert.Equal(0, result.Traits.Count);
    }
Ejemplo n.º 6
0
        public void ToXmlWithDisplayName()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<foo/>");
            XmlNode              parentNode   = doc.ChildNodes[0];
            MethodInfo           method       = typeof(StubClass).GetMethod("Method");
            TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method), "Display Name");

            XmlNode resultNode = methodResult.ToXml(parentNode);

            Assert.Equal("Display Name", resultNode.Attributes["name"].Value);
        }
Ejemplo n.º 7
0
    public void ToXmlWithOutput()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        MethodInfo method = typeof(StubClass).GetMethod("Method");
        TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method), "Display Name");
        methodResult.Output = "This is my output!";

        XmlNode resultNode = methodResult.ToXml(parentNode);

        Assert.Equal("This is my output!", resultNode.SelectSingleNode("output").InnerText);
    }
Ejemplo n.º 8
0
        public void ToXmlWithOutput()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<foo/>");
            XmlNode              parentNode   = doc.ChildNodes[0];
            MethodInfo           method       = typeof(StubClass).GetMethod("Method");
            TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method), "Display Name");

            methodResult.Output = "This is my output!";

            XmlNode resultNode = methodResult.ToXml(parentNode);

            Assert.Equal("This is my output!", resultNode.SelectSingleNode("output").InnerText);
        }
Ejemplo n.º 9
0
        public void ToXmlWithTraits()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            MethodInfo method = typeof(StubClass).GetMethod("MethodWithTraits");
            TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method));

            XmlNode resultNode = methodResult.ToXml(parentNode);

            XmlNode traitsNode = resultNode.SelectSingleNode("traits");
            Assert.NotNull(traitsNode);
            XmlNodeList traitNodes = traitsNode.SelectNodes("trait");
            Assert.Equal("larry", FindTrait(traitNodes, "author").Attributes["value"].Value);
            Assert.Equal("PassedResults", FindTrait(traitNodes, "Class").Attributes["value"].Value);
        }
Ejemplo n.º 10
0
    public void ToXml()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        MethodInfo method = typeof(StubClass).GetMethod("Method");
        TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method));

        XmlNode resultNode = methodResult.ToXml(parentNode);

        Assert.Equal("test", resultNode.Name);
        Assert.Equal(methodResult.TypeName, resultNode.Attributes["type"].Value);
        Assert.Equal(methodResult.MethodName, resultNode.Attributes["method"].Value);
        Assert.Equal(methodResult.TypeName + "." + methodResult.MethodName, resultNode.Attributes["name"].Value);
        Assert.Null(resultNode.SelectSingleNode("traits"));
        Assert.Null(resultNode.SelectSingleNode("output"));
    }
Ejemplo n.º 11
0
        public void ToXml()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<foo/>");
            XmlNode              parentNode   = doc.ChildNodes[0];
            MethodInfo           method       = typeof(StubClass).GetMethod("Method");
            TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method));

            XmlNode resultNode = methodResult.ToXml(parentNode);

            Assert.Equal("test", resultNode.Name);
            Assert.Equal(methodResult.TypeName, resultNode.Attributes["type"].Value);
            Assert.Equal(methodResult.MethodName, resultNode.Attributes["method"].Value);
            Assert.Equal(methodResult.TypeName + "." + methodResult.MethodName, resultNode.Attributes["name"].Value);
            Assert.Null(resultNode.SelectSingleNode("traits"));
            Assert.Null(resultNode.SelectSingleNode("output"));
        }
Ejemplo n.º 12
0
        public void ToXmlWithTraits()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<foo/>");
            XmlNode              parentNode   = doc.ChildNodes[0];
            MethodInfo           method       = typeof(StubClass).GetMethod("MethodWithTraits");
            TestableMethodResult methodResult = new TestableMethodResult(Reflector.Wrap(method));

            XmlNode resultNode = methodResult.ToXml(parentNode);

            XmlNode traitsNode = resultNode.SelectSingleNode("traits");

            Assert.NotNull(traitsNode);
            XmlNodeList traitNodes = traitsNode.SelectNodes("trait");

            Assert.Equal("larry", FindTrait(traitNodes, "author").Attributes["value"].Value);
            Assert.Equal("PassedResults", FindTrait(traitNodes, "Class").Attributes["value"].Value);
        }