public void WarewolfWorkflowReports_Calculte_TotalWorkflowNodesCoveredPercentage_GIVEN_ResourceNotFound_ShouldNotReturnNaN() { var workflowID = Guid.NewGuid(); var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>(); mockWarewolfWorkflow.Setup(o => o.ResourceID) .Returns(workflowID); mockWarewolfWorkflow.Setup(o => o.WorkflowNodes) .Returns(new List <IWorkflowNode>()); var mockTestCoverageCatalog = new Mock <ITestCoverageCatalog>(); mockTestCoverageCatalog.Setup(o => o.Fetch(Guid.Empty)) .Returns(new List <IServiceTestCoverageModelTo> { new ServiceTestCoverageModelTo { AllTestNodesCovered = new ISingleTestNodesCovered[] { } } }); var sut = new WarewolfWorkflowReports(new List <IWarewolfWorkflow> { mockWarewolfWorkflow.Object }, string.Empty); sut.Calculte(mockTestCoverageCatalog.Object, new Mock <ITestCatalog>().Object); Assert.AreEqual(0, sut.TotalWorkflowNodesCount); Assert.AreEqual(0, sut.TotalWorkflowNodesCoveredCount); Assert.AreEqual(0, sut.TotalWorkflowNodesCoveredPercentage, "NaN my not be Ideal to print to user, should rather returning zero"); }
public void WarewolfWorkflowReports_Calculte_TotalWorkflowNodesCoveredPercentage_GIVEN_RecordNameIsAsterick_ShouldReturnReport100() { var workflowID = Guid.NewGuid(); var testName = "Test 1"; var reportName = "*"; var coveredNode_one = Guid.NewGuid(); var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>(); mockWarewolfWorkflow.Setup(o => o.ResourceID) .Returns(workflowID); mockWarewolfWorkflow.Setup(o => o.WorkflowNodes) .Returns(new List <IWorkflowNode> { new WorkflowNode { UniqueID = Guid.NewGuid() }, new WorkflowNode { UniqueID = Guid.NewGuid() } }); var mockTestCoverageCatalog = new Mock <ITestCoverageCatalog>(); mockTestCoverageCatalog.Setup(o => o.Fetch(workflowID)) .Returns(new List <IServiceTestCoverageModelTo> { new ServiceTestCoverageModelTo { ReportName = reportName, AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered(testName, new List <IServiceTestStep> { new ServiceTestStepTO { ActivityID = coveredNode_one, Children = new System.Collections.ObjectModel.ObservableCollection <IServiceTestStep> { new ServiceTestStepTO() } } }) } } }); var sut = new WarewolfWorkflowReports(new List <IWarewolfWorkflow> { mockWarewolfWorkflow.Object }, reportName); sut.Calculte(mockTestCoverageCatalog.Object, new Mock <ITestCatalog>().Object); Assert.AreEqual(2, sut.TotalWorkflowNodesCount); Assert.AreEqual(2, sut.TotalWorkflowNodesCoveredCount); Assert.AreEqual(100, sut.TotalWorkflowNodesCoveredPercentage); }
private static WarewolfWorkflowReports RunListOfCoverage(ICoverageDataObject coverageData, ITestCoverageCatalog testCoverageCatalog, ITestCatalog testCatalog, Guid workspaceGuid, IResourceCatalog catalog) { var resourceReportTemp = new WarewolfWorkflowReports(coverageData.CoverageReportResources, coverageData.ReportName); resourceReportTemp.Calculte(testCoverageCatalog, testCatalog); resourceReportTemp.EndTime = DateTime.Now; return(resourceReportTemp); }
public void WarewolfWorkflowReports_Calculte_TotalWorkflowNodesCoveredPercentage_GIVEN_RecordNameNotFound_ShouldReturnReport() { var workflowID = Guid.NewGuid(); var mockWarewolfWorkflow = new Mock <IWarewolfWorkflow>(); mockWarewolfWorkflow.Setup(o => o.ResourceID) .Returns(workflowID); mockWarewolfWorkflow.Setup(o => o.WorkflowNodes) .Returns(new List <IWorkflowNode> { new WorkflowNode { ActivityID = Guid.NewGuid() }, new WorkflowNode { ActivityID = Guid.NewGuid() }, new WorkflowNode { ActivityID = Guid.NewGuid() }, }); var mockTestCoverageCatalog = new Mock <ITestCoverageCatalog>(); mockTestCoverageCatalog.Setup(o => o.Fetch(workflowID)) .Returns(new List <IServiceTestCoverageModelTo> { new ServiceTestCoverageModelTo { AllTestNodesCovered = new ISingleTestNodesCovered[] { new SingleTestNodesCovered(string.Empty, new List <IServiceTestStep> { new ServiceTestStepTO { ActivityID = Guid.NewGuid(), Children = new System.Collections.ObjectModel.ObservableCollection <IServiceTestStep> { new ServiceTestStepTO { ActivityID = Guid.NewGuid() } } } }) } } }); var sut = new WarewolfWorkflowReports(new List <IWarewolfWorkflow> { mockWarewolfWorkflow.Object }, string.Empty); sut.Calculte(mockTestCoverageCatalog.Object, new Mock <ITestCatalog>().Object); Assert.AreEqual(3, sut.TotalWorkflowNodesCount); Assert.AreEqual(2, sut.TotalWorkflowNodesCoveredCount); Assert.AreEqual(67, 67, sut.TotalWorkflowNodesCoveredPercentage); }