public async Task ValidateSymbolsAsyncWillFailIfTheSnupkgNotSubsetOfNupkg() { // Arrange _symbolsFileService. Setup(sfs => sfs.DownloadNupkgFileAsync(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>())). ReturnsAsync(new MemoryStream()); _symbolsFileService. Setup(sfs => sfs.DownloadSnupkgFileAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())). ReturnsAsync(new MemoryStream()); _zipService.Setup(s => s.ReadFilesFromZipStream(It.IsAny <Stream>(), It.IsAny <string[]>())).Returns(new List <string>() { "foo.dll" }); _zipService.Setup(s => s.ReadFilesFromZipStream(It.IsAny <Stream>(), ".pdb")).Returns(new List <string>() { "bar.pdb" }); var service = new SymbolsValidatorService(_symbolsFileService.Object, _zipService.Object, _telemetryService.Object, _logger.Object); // Act var result = await service.ValidateSymbolsAsync(Message, CancellationToken.None); // Assert Assert.Equal(ValidationResult.Failed.Status, result.Status); Assert.Equal(1, result.Issues.Count); }
public void IsGetSymbolPathValidation(string input, string expectedResult) { // Act string result = SymbolsValidatorService.GetSymbolPath(input); // Assert Assert.Equal(result, expectedResult); }
public TheValidateSymbolMatchingMethod(ITestOutputHelper output) : base(output) { Target = new SymbolsValidatorService( _symbolsFileService.Object, _zipService.Object, _telemetryService.Object, _logger); Directory = TestDirectory.Create(); }
public void SymbolsHaveMatchingNullCheck() { // Arrange string[] symbols = new string[] { @"lib\math\foo.pdb", @"lib\math1\bar.pdb" }; string[] pes = new string[] { @"lib\math\foo.dll", @"lib\math\bar.exe", @"lib\math2\bar2.exe" }; // Act + Assert Assert.Throws <ArgumentNullException>(() => SymbolsValidatorService.SymbolsHaveMatchingPEFiles(null, pes)); Assert.Throws <ArgumentNullException>(() => SymbolsValidatorService.SymbolsHaveMatchingPEFiles(symbols, null)); }
public void SymbolsHaveMatchingPEFilesReturnsFalseWhenPdbsDoNotMatchPEFiles() { // Arrange string[] symbols = new string[] { @"lib\math\foo.pdb", @"lib\math1\bar.pdb" }; string[] pes = new string[] { @"lib\math\foo.dll", @"lib\math\bar.exe", @"lib\math2\bar2.exe" }; // Act var result = SymbolsValidatorService.SymbolsHaveMatchingPEFiles(symbols, pes); // Assert Assert.False(result); }
public void IsPortableValidation(string data, bool expectedResult) { // Arrange + Act bool result = false; using (MemoryStream memStream = new MemoryStream(Encoding.ASCII.GetBytes(data))) { result = SymbolsValidatorService.IsPortable(memStream); } // Assert Assert.Equal(result, expectedResult); }
public void SymbolsHaveMatchingPEFilesReturnsTrueWhenPdbsMatchPEFiles() { // Arrange string[] symbols = new string[] { @"lib\math\foo.pdb", @"lib\math\bar.pdb" }; string[] pes = new string[] { @"lib\math\foo.dll", @"lib\math\bar.exe", @"lib\math2\bar2.exe" }; // Act List <string> orphanSymbols; var result = SymbolsValidatorService.SymbolsHaveMatchingPEFiles(symbols, pes, out orphanSymbols); // Assert Assert.True(result); }
public async Task ValidateSymbolsAsyncWillFailIfSnupkgNotFound() { // Arrange _symbolsFileService. Setup(sfs => sfs.DownloadSnupkgFileAsync(It.IsAny <string>(), It.IsAny <CancellationToken>())). ThrowsAsync(new InvalidOperationException("Snupkg not found")); var service = new SymbolsValidatorService(_symbolsFileService.Object, _zipService.Object, _telemetryService.Object, _logger.Object); // Act var result = await service.ValidateSymbolsAsync(Message, CancellationToken.None); // Assert Assert.Equal(ValidationResult.Failed.Status, result.Status); }