Example #1
0
        public void AllCoverageReports_Given_WithTestReports_IsNotNull_AND_HasALotOfReports_ShouldSuccess()
        {
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes)
            .Returns(_workflow_Three_Nodes);

            var sut = new AllCoverageReports
            {
                EndTime = DateTime.Now
            };

            var coverageReports = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            coverageReports.Add(_test_One_CoverageModelTo);
            coverageReports.Add(_test_One_CoverageModelTo);
            sut.Add(coverageReports);

            var coverageReports_1 = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            coverageReports_1.Add(_test_One_CoverageModelTo);
            coverageReports_1.Add(_test_One_CoverageModelTo);
            sut.Add(coverageReports_1);

            Assert.IsNotNull(sut.StartTime);
            Assert.IsNotNull(sut.EndTime);
            var sss = sut.TotalReportsCoverage;

            Assert.AreEqual(33, sut.TotalReportsCoverage, "code for safety; this should return zero not NaN");
            Assert.AreEqual(2, sut.WithTestReports.ToList().Count, "should be initialized");
        }
        public void WorkflowCoverageReports_GetTotalCoverage_Given_TestNodesCovered_ShouldFailSafe()
        {
            var sdf = Guid.NewGuid();
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode>
            {
                //Should the undesirable happen
            });

            var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "old name",
                ReportName          = "new name",
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            Type       = StepType.Assert
                        }
                    }) }
            });

            Assert.IsNotNull(sut.Resource);
            Assert.IsTrue(sut.HasTestReports);
            Assert.AreEqual(-1, sut.NotCoveredNodesCount, "We might need a deferent approach for handling this matter, with the previous version the one return for safety add on to the count, thus inaccurate count yields");
            Assert.AreEqual(0, sut.TotalCoverage);
        }
        public void WorkflowCoverageReports_GetTotalCoverage_Given_TestNodesCovered_TestStepType_Is_Mock()
        {
            var sdf = Guid.NewGuid();
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode>
            {
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                    UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                }
            });

            var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "old name",
                ReportName          = "new name",
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            Type       = StepType.Mock
                        }
                    }) }
            });

            (double TotalCoverage, _, _) = sut.GetTotalCoverage();

            Assert.IsNotNull(sut.Resource);
            Assert.IsTrue(sut.HasTestReports);
            Assert.AreEqual(0, TotalCoverage);
        }
        public void WorkflowCoverageReports_GetTotalCoverage_Given_TestNodesCovered_TestStepType_Is_Assert_AND_ActivityIDIsEmpty()
        {
            var testUniqueID         = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e");
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode>
            {
                new WorkflowNode
                {
                    ActivityID = Guid.Empty,
                    UniqueID   = testUniqueID, //most of our activities are still using the ActivityID,
                                               //tools like the Gate and newer have started moving towards UniqueID
                }
            });

            var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "old name",
                ReportName          = "new name",
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            Type       = StepType.Assert
                        }
                    }) }
            });

            Assert.IsNotNull(sut.Resource);
            Assert.IsTrue(sut.HasTestReports);
            Assert.AreEqual(1, sut.TotalCoverage);
        }
Example #5
0
        public IServiceTestCoverageModelTo New(Guid workflowId, ICoverageArgs args, List <IServiceTestModelTO> serviceTestModelTos)
        {
            var workflow        = _resourceCatalog.GetWorkflow(workflowId);
            var coverageReports = new WorkflowCoverageReports(workflow);
            var coverageModelTo = new ServiceTestCoverageModelTo
            {
                WorkflowId          = workflowId,
                OldReportName       = args?.OldReportName,
                ReportName          = args?.ReportName,
                LastRunDate         = DateTime.Now,
                AllTestNodesCovered = serviceTestModelTos
                                      .Select(test => new SingleTestNodesCovered(test.TestName, test.TestSteps))
                                      .ToArray()
            };

            coverageReports.Add(coverageModelTo);

            (double TotalCoverage, _, _) = coverageReports.GetTotalCoverage();

            coverageModelTo.TotalCoverage = TotalCoverage;

            return(coverageModelTo);
        }
        public void WorkflowCoverageReports_TryExecute_GetTotalCoverage_Given_ShouldSuccess()
        {
            var sdf = Guid.NewGuid();
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode>
            {
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                    UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                },
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"),
                    UniqueID   = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"),
                },
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"),
                    UniqueID   = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"),
                }
            });

            var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            //passing test
            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "passing test old name",
                ReportName          = "passing test new name",
                TotalCoverage       = .25,
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            Type       = StepType.Assert,
                            Result     = new TestRunResult
                            {
                                RunTestResult = RunResult.TestPassed
                            }
                        }
                    }) }
            });

            //add invalid test
            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "invalid test old name",
                ReportName          = "invalid test new name",
                TotalCoverage       = 0,
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            //this makes for invalid test
                        },
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"),
                            UniqueID   = Guid.Parse("981ff0e1-5604-44ac-ad63-d82eff392882"),
                            Type       = StepType.Mock,
                            Result     = new TestRunResult
                            {
                                RunTestResult = RunResult.TestInvalid
                            }
                        }
                    }) }
            });

            //failing test
            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "failing test old name",
                ReportName          = "failing test new name",
                TotalCoverage       = 0.1,
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"),
                            UniqueID   = Guid.Parse("58df5745-c1c7-43fa-bb12-30c890dd7223"),
                            Type       = StepType.Assert,
                            Result     = new TestRunResult
                            {
                                RunTestResult = RunResult.TestFailed
                            }
                        }
                    }) }
            });

            var result = sut.TryExecute();

            Assert.IsNotNull(result.Resource);
            Assert.IsTrue(result.HasTestReports);
            Assert.AreEqual(1, result.TotalCoverage, "design change: mocked nodes should now included with the test coverage calculation");
        }
        public void WorkflowCoverageReports_GetTotalCoverage_Given_ChildNodes_ShouldInheritParentCoverageStatus()
        {
            var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>();

            mockWarewolfWorkflow.Setup(o => o.WorkflowNodes).Returns(new List <IWorkflowNode>
            {
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                    UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                    ChildNodes = new List <IWorkflowNode>
                    {
                        new WorkflowNode
                        {
                            ActivityID   = Guid.Parse("37f61bbe-c77b-4066-be7e-e91706382e82"),
                            UniqueID     = Guid.Parse("37f61bbe-c77b-4066-be7e-e91706382e82"),
                            MockSelected = false
                        }
                    }
                },
                new WorkflowNode
                {
                    ActivityID = Guid.Parse("fc647f71-9879-4823-8b2c-04b63e395ba2"),
                    UniqueID   = Guid.Parse("fc647f71-9879-4823-8b2c-04b63e395ba2"),
                    ChildNodes = new List <IWorkflowNode>
                    {
                        new WorkflowNode
                        {
                            ActivityID   = Guid.Parse("7615414c-8f33-4175-96a7-3f961918c4d4"),
                            UniqueID     = Guid.Parse("7615414c-8f33-4175-96a7-3f961918c4d4"),
                            MockSelected = false
                        }
                    }
                }
            });

            var sut = new WorkflowCoverageReports(mockWarewolfWorkflow.Object);

            sut.Add(new ServiceTestCoverageModelTo
            {
                WorkflowId          = Guid.NewGuid(),
                LastRunDate         = DateTime.Now,
                OldReportName       = "old name",
                ReportName          = "new name",
                AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered("Test", new List <IServiceTestStep>
                    {
                        new ServiceTestStepTO
                        {
                            ActivityID = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            UniqueID   = Guid.Parse("7ed4ab9c-d227-409a-acc3-18330fe6b84e"),
                            Type       = StepType.Mock,
                            Children   = new System.Collections.ObjectModel.ObservableCollection <IServiceTestStep>
                            {
                                new ServiceTestStepTO
                                {
                                    ActivityID   = Guid.Parse("37f61bbe-c77b-4066-be7e-e91706382e82"),
                                    UniqueID     = Guid.Parse("37f61bbe-c77b-4066-be7e-e91706382e82"),
                                    MockSelected = false
                                }
                            }
                        },
                    }) }
            });

            Assert.IsNotNull(sut.Resource);
            Assert.IsTrue(sut.HasTestReports);
            Assert.AreEqual(.5, sut.TotalCoverage, "design change: child nodes should now included with the test coverage calculation");
        }