Example #1
0
        public void DoPutAction_ExecuteOperation_IsPathRooted_True_ImpersonatedUser_IsNotNull_FileExist_IsNotBase64String_ExpectSuccess()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO         = new Mock <IDev2CRUDOperationTO>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockFileStreamFactory           = new Mock <IFileStreamFactory>();
            var mockMemoryStreamFactory         = new Mock <IMemoryStreamFactory>();
            var mockFilePath                    = new Mock <IFilePath>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();

            var path = "testPath";

            mockFileStreamFactory.Setup(o => o.New(path, FileMode.Append)).Returns(new MemoryStream());
            mockMemoryStreamFactory.Setup(o => o.New(It.IsAny <byte[]>())).Returns(new MemoryStream());
            mockFilePath.Setup(o => o.IsPathRooted(It.IsAny <string>())).Returns(true);
            mockActivityIOPath.Setup(o => o.Path).Returns(path);
            mockDev2CRUDOperationTO.Setup(o => o.Overwrite).Returns(false);

            var ss = new DoPutAction(new MemoryStream(Encoding.ASCII.GetBytes("disIsnnOtaBase64sTrIng=3421")), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, "TestWhere", mockDev2LogonProvider.Object, mockFileWrapper.Object, mockFileStreamFactory.Object, mockFilePath.Object, mockMemoryStreamFactory.Object, (arg1, arg2) => mockWindowsImpersonationContext.Object);
            //-------------------------Act---------------------------
            var xx = ss.ExecuteOperation();

            //-------------------------Assert------------------------
            mockFilePath.VerifyAll();
            mockActivityIOPath.VerifyAll();
            mockDev2CRUDOperationTO.VerifyAll();
            Assert.AreEqual(27, xx);
        }
Example #2
0
        public void DoPutAction_ExecuteOperation_ExpectIOException()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath      = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>();

            var ss = new DoPutAction(new MemoryStream(), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, "testWhereToPut");

            //-------------------------Act---------------------------
            //-------------------------Assert------------------------
            Assert.ThrowsException <IOException>(() => ss.ExecuteOperation());
        }
Example #3
0
        public void DoPutAction_ExecuteOperation_IsPathRooted_True__ImpersonatedUser_IsNull_ExpectArgumentNullException()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath      = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>();
            var mockDev2LogonProvider   = new Mock <IDev2LogonProvider>();
            var mockFileWrapper         = new Mock <IFile>();
            var mockFilePath            = new Mock <IFilePath>();

            mockFilePath.Setup(o => o.IsPathRooted(It.IsAny <string>())).Returns(true);

            var ss = new DoPutAction(new MemoryStream(), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, null, mockDev2LogonProvider.Object, mockFileWrapper.Object, mockFilePath.Object, (arg1, arg2) => null);

            //-------------------------Act---------------------------
            //-------------------------Assert------------------------
            Assert.ThrowsException <ArgumentNullException>(() => ss.ExecuteOperation());
        }
Example #4
0
        public void DoPutAction_ExecuteOperation_IsPathRooted_false_ExpectIOException()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO         = new Mock <IDev2CRUDOperationTO>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockFilePath                    = new Mock <IFilePath>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();

            mockFilePath.Setup(o => o.IsPathRooted(It.IsAny <string>())).Returns(false);

            var ss = new DoPutAction(new MemoryStream(), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, "TestWhere", mockDev2LogonProvider.Object, mockFileWrapper.Object, new Mock <IFileStreamFactory>().Object, mockFilePath.Object, new Mock <IMemoryStreamFactory>().Object, (arg1, arg2) => mockWindowsImpersonationContext.Object);

            //-------------------------Act---------------------------
            //-------------------------Assert------------------------
            Assert.ThrowsException <IOException>(() => ss.ExecuteOperation());
        }
Example #5
0
        public void DoPutAction_ExecuteOperation_IsPathRooted_True_ImpersonatedUser_IsNull_ExpectTrue()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO         = new Mock <IDev2CRUDOperationTO>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockFilePath                    = new Mock <IFilePath>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();

            mockFilePath.Setup(o => o.IsPathRooted(It.IsAny <string>())).Returns(true);
            mockActivityIOPath.Setup(o => o.Path).Returns("testPath");

            var ss = new DoPutAction(new MemoryStream(), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, null, mockDev2LogonProvider.Object, mockFileWrapper.Object, mockFilePath.Object, (arg1, arg2) => mockWindowsImpersonationContext.Object);
            //-------------------------Act---------------------------
            var xx = ss.ExecuteOperation();

            //-------------------------Assert------------------------
            mockFilePath.VerifyAll();
            mockActivityIOPath.VerifyAll();
            Assert.AreEqual(0, xx);
        }
Example #6
0
        public void DoPutAction_ExecuteOperation_IsPathRooted_True__ImpersonatedUser_IsNull_ExpectArgumentNullException()
        {
            //-------------------------Arrange-----------------------
            var mockActivityIOPath              = new Mock <IActivityIOPath>();
            var mockDev2CRUDOperationTO         = new Mock <IDev2CRUDOperationTO>();
            var mockDev2LogonProvider           = new Mock <IDev2LogonProvider>();
            var mockFileWrapper                 = new Mock <IFile>();
            var mockFilePath                    = new Mock <IFilePath>();
            var mockWindowsImpersonationContext = new Mock <IWindowsImpersonationContext>();
            var mockFileStreamFactory           = new Mock <IFileStreamFactory>();
            var mockMemoryStreamFactory         = new Mock <IMemoryStreamFactory>();

            mockMemoryStreamFactory.Setup(o => o.New(It.IsAny <byte[]>())).Throws(new ArgumentNullException());
            mockActivityIOPath.Setup(o => o.Path).Returns("src/path");
            mockFileStreamFactory.Setup(o => o.New(It.IsAny <string>(), FileMode.Append)).Returns(new MemoryStream());
            mockFilePath.Setup(o => o.IsPathRooted(It.IsAny <string>())).Returns(true);

            var ss = new DoPutAction(new MemoryStream(), mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, "TestWhere", mockDev2LogonProvider.Object, mockFileWrapper.Object, mockFileStreamFactory.Object, mockFilePath.Object, mockMemoryStreamFactory.Object, (arg1, arg2) => null);

            //-------------------------Act---------------------------
            //-------------------------Assert------------------------
            Assert.ThrowsException <ArgumentNullException>(() => ss.ExecuteOperation());
        }