コード例 #1
0
        public void Dev2FTPProvider_Delete_PathType_File_DeleteOp()
        {
            const string path           = ".path";
            const string userName       = "******";
            const string password       = "******";
            const string privateKeyFile = "privateKeyFile";

            var mockActivityIOPath = new Mock <IActivityIOPath>();

            mockActivityIOPath.Setup(activityIOPath => activityIOPath.PathType).Returns(Interfaces.Enums.enActivityIOPathType.FileSystem);
            mockActivityIOPath.Setup(activityIOPath => activityIOPath.Path).Returns(path);
            mockActivityIOPath.Setup(activityIOPath => activityIOPath.Username).Returns(userName);
            mockActivityIOPath.Setup(activityIOPath => activityIOPath.Password).Returns(password);
            mockActivityIOPath.Setup(activityIOPath => activityIOPath.PrivateKeyFile).Returns(privateKeyFile);

            var activityIOPathList = new List <IActivityIOPath> {
                mockActivityIOPath.Object
            };

            var mockImplementation = new Mock <IImplementation>();

            mockImplementation.Setup(implementation => implementation.PathIs(mockActivityIOPath.Object)).Returns(Interfaces.Enums.enPathType.File);
            mockImplementation.Setup(implementation => implementation.DeleteOp(activityIOPathList));

            var dev2FTPProvider = new Dev2FTPProvider(mockImplementation.Object);
            var result          = dev2FTPProvider.Delete(mockActivityIOPath.Object);

            Assert.IsTrue(result);
            mockImplementation.Verify(implementation => implementation.DeleteOp(activityIOPathList), Times.Once);
        }
コード例 #2
0
        public void Dev2FTPProvider_Delete_ExpectedException()
        {
            const string path = "path";
            var          mockActivityIOPath = new Mock <IActivityIOPath>();

            mockActivityIOPath.Setup(activityIOPath => activityIOPath.Path).Returns(path);

            var dev2FTPProvider = new Dev2FTPProvider(null);

            try
            {
                dev2FTPProvider.Delete(mockActivityIOPath.Object);
                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);
            }
        }