public void PassedResultIsReturnedIfInnerCommandPasses([Frozen] string displayName, [Frozen] ITestCommand innerCommand, ParadigmTestCommand sut, PassedResult innerCommandResult)
        {
            Mock.Get(innerCommand).Setup(x => x.Execute(It.IsAny<object>()))
                .Returns(innerCommandResult);

            var result = sut.Execute(null);

            Assert.That(result, Describe.Object<MethodResult>()
                .Cast<PassedResult>(c => c.Property(x => x.DisplayName, Is.EqualTo(displayName))));
        }
Ejemplo n.º 2
0
        public void ToXml()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            MethodInfo method = typeof(StubClass).GetMethod("StubMethod");
            PassedResult passedResult = new PassedResult(Reflector.Wrap(method), null);
            passedResult.ExecutionTime = 1.2;

            XmlNode resultNode = passedResult.ToXml(parentNode);

            Assert.Equal("Pass", resultNode.Attributes["result"].Value);
            Assert.Equal("1.200", resultNode.Attributes["time"].Value);
            Assert.Null(resultNode.SelectSingleNode("failure"));
            Assert.Null(resultNode.SelectSingleNode("reason"));
        }
Ejemplo n.º 3
0
    public void ToXml_WithChildren()
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml("<foo/>");
        XmlNode parentNode = doc.ChildNodes[0];
        PassedResult passedResult = new PassedResult("foo", "bar", null, null);
        passedResult.ExecutionTime = 1.1;
        FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack");
        failedResult.ExecutionTime = 2.2;
        SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason");
        ClassResult classResult = new ClassResult(typeof(object));
        classResult.Add(passedResult);
        classResult.Add(failedResult);
        classResult.Add(skipResult);
        AssemblyResult assemblyResult = new AssemblyResult(filename);
        assemblyResult.Add(classResult);

        XmlNode resultNode = assemblyResult.ToXml(parentNode);

        Assert.Equal("3.300", resultNode.Attributes["time"].Value);
        Assert.Equal("3", resultNode.Attributes["total"].Value);
        Assert.Equal("1", resultNode.Attributes["passed"].Value);
        Assert.Equal("1", resultNode.Attributes["failed"].Value);
        Assert.Equal("1", resultNode.Attributes["skipped"].Value);
        Assert.Single(resultNode.SelectNodes("class"));
    }
        public void TestInstanceIsDisposedAfter([Frozen] IObjectFactory instanceFactory, [Frozen] ITestCommand innerCommand, ParadigmTestCommand sut, IDisposable createdTestClass, PassedResult commandResult)
        {
            Mock.Get(instanceFactory).Setup(x => x.CreateInstance()).Returns(createdTestClass);

            Mock.Get(innerCommand).Setup(x => x.Execute(It.IsAny<object>()))
                .Returns(commandResult);

            sut.Execute(null);

            Mock.Get(createdTestClass).Verify(x => x.Dispose());
        }
Ejemplo n.º 5
0
        public void ToXmlTwiceDoesNotDoubleCounts()
        {
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<foo/>");
            XmlNode parentNode = doc.ChildNodes[0];
            ClassResult classResult = new ClassResult(typeof(object));
            PassedResult passedResult = new PassedResult("foo", "bar", null, null);
            passedResult.ExecutionTime = 1.1;
            FailedResult failedResult = new FailedResult("foo", "bar", null, null, "extype", "message", "stack");
            failedResult.ExecutionTime = 2.2;
            SkipResult skipResult = new SkipResult("foo", "bar", null, null, "reason");
            classResult.Add(passedResult);
            classResult.Add(failedResult);
            classResult.Add(skipResult);

            XmlNode resultNode1 = classResult.ToXml(parentNode);
            XmlNode resultNode2 = classResult.ToXml(parentNode);

            Assert.Equal(resultNode1.Attributes["time"].Value, resultNode2.Attributes["time"].Value);
            Assert.Equal(resultNode1.Attributes["total"].Value, resultNode2.Attributes["total"].Value);
            Assert.Equal(resultNode1.Attributes["passed"].Value, resultNode2.Attributes["passed"].Value);
            Assert.Equal(resultNode1.Attributes["failed"].Value, resultNode2.Attributes["failed"].Value);
            Assert.Equal(resultNode1.Attributes["skipped"].Value, resultNode2.Attributes["skipped"].Value);
            Assert.Equal(resultNode1.SelectNodes("test").Count, resultNode2.SelectNodes("test").Count);
        }