예제 #1
0
        public async Task EmptyFileGenerated_When_NoLogsExist()
        {
            // Arrange
            var logs = LogFactory.CreateEmpty();

            _logRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(logs));
            _directoryProvider.Setup(x => x.DoesDirectoryExists(It.IsAny <string>())).Returns(true);
            _dateTimeProvider.Setup(x => x.GetCurrentTime()).Returns(DateTime.Now);
            _pathProvider.Setup(x => x.Combine(It.IsAny <string>(), It.IsAny <string>())).Returns((string path1, string filePath) => Path.Combine(path1, filePath));
            _fileProvider.Setup(x => x.WriteAllText(It.IsAny <string>(), It.IsAny <string>())).Callback((string filePath, string content) => File.WriteAllText(filePath, content));
            string dumpFileLocation        = DirectoryFactory.CreateTestDirectory();
            var    exceptionLogDumpCreator = new DistributeLogDumpCreator(
                _logRepositoryMock.Object,
                _dateTimeProvider.Object,
                _fileProvider.Object,
                _directoryProvider.Object,
                _pathProvider.Object,
                _consoleProvider.Object,
                _reflectionProvider.Object);

            // Act
            string dumpFile = await exceptionLogDumpCreator.CreateDumpAsync(dumpFileLocation);

            // Assert
            string dumpFileContent = File.ReadAllText(dumpFile);

            Assert.That(dumpFileContent, Is.EqualTo(string.Empty));
        }
예제 #2
0
        public async Task LogsDeleted_When_NoLogsExist()
        {
            // Arrange
            var logs = LogFactory.CreateEmpty();

            _logRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(logs));

            var exceptionLogDumpCreator = new DistributeLogDumpCreator(
                _logRepositoryMock.Object,
                _dateTimeProvider.Object,
                _fileProvider.Object,
                _directoryProvider.Object,
                _pathProvider.Object,
                _consoleProvider.Object,
                _reflectionProvider.Object);

            // Act
            await exceptionLogDumpCreator.DeleteAllDumpsAsync();

            // Assert
            await exceptionLogDumpCreator.DeleteAllDumpsAsync();
        }