public void DoPathExistOperation_CTOR_Path_IsNull_ExpectNullReferenceException() { //--------------------------Arrange------------------------- var mockActivityIOPath = new Mock <IActivityIOPath>(); var doPathExistOperation = new DoPathExistOperation(mockActivityIOPath.Object); //--------------------------Act----------------------------- //--------------------------Assert-------------------------- Assert.ThrowsException <NullReferenceException>(() => doPathExistOperation.ExecuteOperation()); }
public void DoPathExistOperation_ImpersonatedUser_Null_IsFalse_ExpectFalse() { //--------------------------Arrange------------------------- var mockActivityIOPath = new Mock <IActivityIOPath>(); var mockDev2LogonProvider = new Mock <IDev2LogonProvider>(); var mockfileWrapper = new Mock <IFile>(); var mockDirectory = new Mock <IDirectory>(); mockActivityIOPath.Setup(o => o.Path).Returns("testPath"); var doPathExistOperation = new DoPathExistOperation(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockfileWrapper.Object, mockDirectory.Object, (arg1, arg2) => null); //--------------------------Act----------------------------- var isExecuteOperation = doPathExistOperation.ExecuteOperation(); //--------------------------Assert-------------------------- mockActivityIOPath.VerifyAll(); Assert.IsFalse(isExecuteOperation); }
public void DoPathExistOperation_ExecuteOperationWithAuth_IsNull_FileWrapperPathExists_IsFalse_ExpectFalse() { //--------------------------Arrange------------------------- var mockActivityIOPath = new Mock <IActivityIOPath>(); var mockDev2LogonProvider = new Mock <IDev2LogonProvider>(); var mockfileWrapper = new Mock <IFile>(); var mockDirectory = new Mock <IDirectory>(); mockActivityIOPath.Setup(o => o.Path).Returns("ftp://testPath/looger.log"); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true); var doPathExistOperation = new DoPathExistOperation(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockfileWrapper.Object, mockDirectory.Object, (arg1, arg2) => null); //--------------------------Act----------------------------- var isExecuteOperation = doPathExistOperation.ExecuteOperationWithAuth(); //--------------------------Assert-------------------------- mockActivityIOPath.VerifyAll(); mockDirectory.VerifyAll(); Assert.IsFalse(isExecuteOperation); }
public void DoPathExistOperation_ImpersonatedUser_IsNotNull_PathExists_IsTrue_ExpectTrue() { //--------------------------Arrange------------------------- var mockActivityIOPath = new Mock <IActivityIOPath>(); var mockDev2LogonProvider = new Mock <IDev2LogonProvider>(); var mockfileWrapper = new Mock <IFile>(); var mockDirectory = new Mock <IDirectory>(); var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>(); mockActivityIOPath.Setup(o => o.Path).Returns("testPath"); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true); var doPathExistOperation = new DoPathExistOperation(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockfileWrapper.Object, mockDirectory.Object, (arg1, arg2) => mockWindowsImpersonationContext.Object); //--------------------------Act----------------------------- var isExecuteOperation = doPathExistOperation.ExecuteOperation(); //--------------------------Assert-------------------------- mockActivityIOPath.VerifyAll(); mockDirectory.VerifyAll(); Assert.IsTrue(isExecuteOperation); }