コード例 #1
0
 public void UnauthorizedAccessExceptionThrown_ErrorRegistered()
 {
     // Arrange
     var dirServiceStub = new Moq.Mock<IDirService>();
     dirServiceStub.Setup(s => s.DirectoryExists(Moq.It.IsAny<string>())).Returns(true);
     dirServiceStub.Setup(s => s.GetDirectories("a")).Throws<UnauthorizedAccessException>();
     var filesFinder = new FilesFinder(dirServiceStub.Object);
     // Act
     filesFinder.SearchWithSameNames("a");
     // Assert
     Assert.AreEqual(1, filesFinder.GetLastErrors().Count);
 }
コード例 #2
0
 public void PassingNonExistingDirectory_RegistersError__CustomStub()
 {
     // Arrange
     var dirService = new DirServiceStub();
     dirService.DirectoryExistsResult = false;
     var filesFinder = new FilesFinder(dirService);
     // Act
     filesFinder.SearchWithSameNames("NonExisting");
     // Assert
     Assert.AreEqual(1, filesFinder.GetLastErrors().Count, "Non existing directory error expected");
 }
コード例 #3
0
 public void PassingNonExistingDirectory_RegistersError__MoqStub()
 {
     // Arrange
     var dirServiceStub = new Moq.Mock<IDirService>();
     dirServiceStub.Setup(s => s.DirectoryExists("NonExisting")).Returns(false);
     var filesFinder = new FilesFinder(dirServiceStub.Object);
     // Act
     filesFinder.SearchWithSameNames("NonExisting");
     // Assert
     Assert.AreEqual(1, filesFinder.GetLastErrors().Count, "Non existing directory error expected");
 }
コード例 #4
0
 public void SearchWithSameNames_PassingNonExistingDirectory_RegistersError()
 {
     // Arrange
     var filesFinder = new FilesFinder();
     // Act
     string nonExistingDir = Path.Combine(RootTestDir, "NonExisting");
     filesFinder.SearchWithSameNames(nonExistingDir);
     // Assert
     Assert.AreEqual(1, filesFinder.GetLastErrors().Count, "Non existing directory error expected");
 }