public void TestRunMessagesNotUpdated_When_NoNewTestRunLogMessagesExist() { // Arrange var fixture = new Fixture(); var expectedTestRunId = fixture.Create <Guid>(); var testRunLogs = TestRunLogFactory.CreateMany(expectedTestRunId); _testRunLogRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(testRunLogs)); var testAgentsLoggerServicePrivate = new TestAgentsLoggerService(_testRunLogRepositoryMock.Object, _taskProviderMock.Object, _consoleProviderMock.Object); // Act testAgentsLoggerServicePrivate.LogTestRunMessages(expectedTestRunId); // Assert _consoleProviderMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Never()); _testRunLogRepositoryMock.Verify(x => x.GetAsync(It.IsAny <int>()), Times.Never()); _testRunLogRepositoryMock.Verify(x => x.UpdateAsync(It.IsAny <int>(), It.IsAny <TestRunLogDto>()), Times.Never()); }
public void OneTestRunMessageUpdated_When_OneTestRunLogMessageExistsInStatusNew() { // Arrange var fixture = new Fixture(); var expectedTestRunId = fixture.Create <Guid>(); var actualTestRunLog = default(TestRunLogDto); var testRunLogs = TestRunLogFactory.CreateMany(expectedTestRunId, TestRunLogStatus.New, 1); _testRunLogRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(testRunLogs)); _testRunLogRepositoryMock.Setup(x => x.UpdateAsync(It.IsAny <int>(), It.IsAny <TestRunLogDto>())).Callback((TestRunLogDto testRunLog) => actualTestRunLog = testRunLog); var testAgentsLoggerServicePrivate = new TestAgentsLoggerService(_testRunLogRepositoryMock.Object, _taskProviderMock.Object, _consoleProviderMock.Object); // Act testAgentsLoggerServicePrivate.LogTestRunMessages(expectedTestRunId); // Assert _consoleProviderMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Once()); _testRunLogRepositoryMock.Verify(x => x.GetAsync(It.IsAny <int>()), Times.Once()); Assert.That(actualTestRunLog.Status, Is.EqualTo(TestRunLogStatus.Published)); }
public async Task TwoTestRunMessagesUpdated_When_TwoTestRunLogMessagesExistInStatusNew() { // Arrange var fixture = new Fixture(); var expectedTestRunId = fixture.Create <Guid>(); List <TestRunLogDto> actualTestRunLogs = new List <TestRunLogDto>(); var testRunLogs = TestRunLogFactory.CreateMany(expectedTestRunId, TestRunLogStatus.New, 2); Debug.WriteLine(testRunLogs.Count()); _testRunLogRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(testRunLogs)); _testRunLogRepositoryMock.Setup(x => x.UpdateAsync(It.IsAny <int>(), It.IsAny <TestRunLogDto>())).Callback((TestRunLogDto testRunLog) => actualTestRunLogs.Add(testRunLog)); var testAgentsLoggerServicePrivate = new TestAgentsLoggerService(_testRunLogRepositoryMock.Object, _taskProviderMock.Object, _consoleProviderMock.Object); // Act testAgentsLoggerServicePrivate.LogTestRunMessages(expectedTestRunId); // Assert _consoleProviderMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(2)); _testRunLogRepositoryMock.Verify(x => x.GetAsync(It.IsAny <int>()), Times.Exactly(2)); Assert.That(actualTestRunLogs[0].Status, Is.EqualTo(TestRunLogStatus.Published)); Assert.That(actualTestRunLogs[1].Status, Is.EqualTo(TestRunLogStatus.Published)); }