public void ZeroSuites() { var now = DateTime.Now; var suiteDtos = new List <SuiteDto>(); var mockSuiteService = new Mock <ISuiteService>(); mockSuiteService.Setup(s => s.GetAll()).Returns(suiteDtos); var temporaryTestResults = new List <TemporaryTestResult>(); var mockTemporaryTestResults = temporaryTestResults.ToDbSetMock(); mockTemporaryTestResults.Setup(m => m.AsNoTracking()).Returns(mockTemporaryTestResults.Object); var mockContext = new Mock <ZigNetEntities>(); mockContext.Setup(m => m.TemporaryTestResults).Returns(mockTemporaryTestResults.Object); var zignetEntitiesWrapperMock = new Mock <IDbContext>(); zignetEntitiesWrapperMock.Setup(z => z.Get()).Returns(mockContext.Object); var latestSuiteResultsService = new LatestSuiteResultsService(zignetEntitiesWrapperMock.Object, mockSuiteService.Object); var suiteSummaries = latestSuiteResultsService.GetLatestGrouped().ToList(); Assert.AreEqual(0, suiteSummaries.Count); }
public void ZeroTestsInSuite() { var now = DateTime.Now; var suiteDtos = new List <SuiteDto> { new SuiteDto { SuiteID = 1, ApplicationNameAbbreviation = "LN", EnvironmentNameAbbreviation = "TSM" }, new SuiteDto { SuiteID = 2, ApplicationNameAbbreviation = "LN", EnvironmentNameAbbreviation = "TSM" } }; var mockSuiteService = new Mock <ISuiteService>(); mockSuiteService.Setup(s => s.GetAll()).Returns(suiteDtos); var temporaryTestResults = new List <TemporaryTestResult> { new TemporaryTestResult { SuiteId = 1, TestResultTypeId = 1 }, new TemporaryTestResult { SuiteId = 1, TestResultTypeId = 1 }, new TemporaryTestResult { SuiteId = 1, TestResultTypeId = 1 } }; var mockTemporaryTestResults = temporaryTestResults.ToDbSetMock(); mockTemporaryTestResults.Setup(m => m.AsNoTracking()).Returns(mockTemporaryTestResults.Object); var mockContext = new Mock <ZigNetEntities>(); mockContext.Setup(m => m.TemporaryTestResults).Returns(mockTemporaryTestResults.Object); var zignetEntitiesWrapperMock = new Mock <IDbContext>(); zignetEntitiesWrapperMock.Setup(z => z.Get()).Returns(mockContext.Object); var latestSuiteResultsService = new LatestSuiteResultsService(zignetEntitiesWrapperMock.Object, mockSuiteService.Object); var suiteSummaries = latestSuiteResultsService.GetLatestGrouped().ToList(); Assert.AreEqual(1, suiteSummaries.Count); Assert.AreEqual("LN TSM", suiteSummaries[0].SuiteName); Assert.AreEqual(2, suiteSummaries[0].SuiteIds.Count); var suiteIds = suiteSummaries[0].SuiteIds.OrderBy(s => s).ToList(); Assert.AreEqual(1, suiteIds[0]); Assert.AreEqual(2, suiteIds[1]); Assert.IsNull(suiteSummaries[0].SuiteEndTime); Assert.AreEqual(3, suiteSummaries[0].TotalFailedTests); Assert.AreEqual(0, suiteSummaries[0].TotalInconclusiveTests); Assert.AreEqual(0, suiteSummaries[0].TotalPassedTests); }