Exemplo n.º 1
0
        public void DoGetAction_ExecuteOperation__ImpersonatedUser_IsNull_ExpectException()
        {
            //------------------------Arrange--------------------------
            var mockActivityIOPath = new Mock <IActivityIOPath>();

            var doGetAction = new DoGetAction(mockActivityIOPath.Object);

            //------------------------Act------------------------------
            //------------------------Assert---------------------------
            Assert.ThrowsException <Exception>(() => doGetAction.ExecuteOperation());
        }
Exemplo n.º 2
0
        public void DoGetAction_ExecuteOperation__ImpersonatedUser_IsNotNull_Catch_ExpectTrue()
        {
            //------------------------Arrange--------------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();

            mockActivityIOPath.Setup(o => o.Path).Throws <Exception>();

            var doGetAction = new DoGetAction(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockFileWrapper.Object, (arg1, arg2) => mockWindowsImpersonationContext.Object);

            //------------------------Act------------------------------
            //------------------------Assert---------------------------
            Assert.ThrowsException <Exception>(() => doGetAction.ExecuteOperation());
        }
Exemplo n.º 3
0
        public void DoGetAction_ExecuteOperation__ImpersonatedUser_IsNotNull_IsTrue_ExpectTrue()
        {
            //------------------------Arrange--------------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();

            var doGetAction = new DoGetAction(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockFileWrapper.Object, (arg1, arg2) => mockWindowsImpersonationContext.Object);
            //------------------------Act------------------------------
            var executeOperation = doGetAction.ExecuteOperation();

            //------------------------Assert---------------------------
            Assert.IsTrue(executeOperation.CanRead);
            Assert.IsTrue(executeOperation.CanSeek);
            Assert.IsFalse(executeOperation.CanTimeout);
            Assert.IsTrue(executeOperation.CanWrite);
        }
Exemplo n.º 4
0
        public void DoGetAction_ExecuteOperation__ImpersonatedUser_IsNull_ExpectTrue()
        {
            //------------------------Arrange--------------------------
            var mockActivityIOPath    = new Mock <IActivityIOPath>();
            var mockDev2LogonProvider = new Mock <IDev2LogonProvider>();
            var mockFileWrapper       = new Mock <IFile>();

            mockFileWrapper.Setup(o => o.Exists(It.IsAny <string>())).Returns(true);

            var doGetAction = new DoGetAction(mockActivityIOPath.Object, mockDev2LogonProvider.Object, mockFileWrapper.Object, (arg1, arg2) => null);
            //------------------------Act------------------------------
            var executeOperation = doGetAction.ExecuteOperation();

            //------------------------Assert---------------------------
            mockFileWrapper.VerifyAll();
            Assert.IsTrue(executeOperation.CanRead);
            Assert.IsTrue(executeOperation.CanSeek);
            Assert.IsFalse(executeOperation.CanTimeout);
            Assert.IsTrue(executeOperation.CanWrite);
        }