Example #1
0
        public void Dev2FTPProvider_Put_OverWrite_WriteToSftp()
        {
            Stream streamResult   = new MemoryStream(new byte[0]);
            var    filesToCleanup = new List <string>();
            var    whereToPut     = string.Empty;

            var mockActivityIOPath = new Mock <IActivityIOPath>();

            mockActivityIOPath.Setup(activityIOPath => activityIOPath.PathType).Returns(Interfaces.Enums.enActivityIOPathType.FileSystem);

            var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>();

            mockDev2CRUDOperationTO.Setup(dev2CRUDOperationTO => dev2CRUDOperationTO.Overwrite).Returns(true);

            var mockImplementation = new Mock <IImplementation>();

            mockImplementation.Setup(implementation => implementation.IsStandardFtp(mockActivityIOPath.Object)).Returns(false);
            mockImplementation.Setup(implementation => implementation.WriteToSftp(streamResult, mockActivityIOPath.Object)).Returns(1);

            var dev2FTPProvider = new Dev2FTPProvider(mockImplementation.Object);
            var result          = dev2FTPProvider.Put(streamResult, mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, whereToPut, filesToCleanup);

            Assert.AreEqual(1, result);
            mockImplementation.Verify(implementation => implementation.WriteToSftp(streamResult, mockActivityIOPath.Object), Times.Once);
        }
Example #2
0
        public void Dev2FTPProvider_Put_ExpectedException_All()
        {
            Stream streamResult   = new MemoryStream(new byte[0]);
            var    filesToCleanup = new List <string>();
            var    whereToPut     = string.Empty;

            var mockActivityIOPath = new Mock <IActivityIOPath>();

            mockActivityIOPath.Setup(activityIOPath => activityIOPath.PathType).Returns(Interfaces.Enums.enActivityIOPathType.FileSystem);

            var mockDev2CRUDOperationTO = new Mock <IDev2CRUDOperationTO>();

            mockDev2CRUDOperationTO.Setup(dev2CRUDOperationTO => dev2CRUDOperationTO.Overwrite).Returns(false);

            var mockImplementation = new Mock <IImplementation>();

            mockImplementation.Setup(implementation => implementation.IsStandardFtp(mockActivityIOPath.Object)).Returns(true);
            mockImplementation.Setup(implementation => implementation.WriteToFtp(streamResult, mockActivityIOPath.Object)).Returns(1);

            var dev2FTPProvider = new Dev2FTPProvider(null);

            try
            {
                dev2FTPProvider.Put(streamResult, mockActivityIOPath.Object, mockDev2CRUDOperationTO.Object, whereToPut, filesToCleanup);
                Assert.Fail("Code should have caused an exception to be thrown");
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message);
            }
        }