Example #1
0
        public void PerformExecution_GivenPaths_ShouldPassthrough()
        {
            //---------------Set up test pack-------------------
            var mockExecutor  = new Mock <IDropboxSingleExecutor <IDropboxResult> >();
            var clientWrapper = new Mock <IDropboxClientWrapper>();

            clientWrapper.Setup(wrapper => wrapper.UploadAsync(It.IsAny <string>(), It.IsAny <WriteMode>(), It.IsAny <bool>(), null, It.IsAny <bool>(), It.IsAny <MemoryStream>()))
            .Returns(Task.FromResult(TestConstant.FileMetadataInstance.Value));
            mockExecutor.Setup(executor => executor.ExecuteTask(clientWrapper.Object))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dsfDropBoxUploadAcivtityMock = new DsfDropBoxUploadActivityMock(mockExecutor.Object, clientWrapper.Object)
            {
                IsUplodValidSuccess = true
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dsfDropBoxUploadAcivtityMock);
            //---------------Execute Test ----------------------
            var location = Assembly.GetExecutingAssembly().Location;

            dsfDropBoxUploadAcivtityMock.PerfomBaseExecution(new Dictionary <string, string>()
            {
                { "ToPath", "a" },
                { "FromPath", location },
            });
            //---------------Test Result -----------------------
            clientWrapper.Verify(wrapper => wrapper.UploadAsync(It.IsAny <string>(), It.IsAny <WriteMode>(), It.IsAny <bool>(), null, It.IsAny <bool>(), It.IsAny <MemoryStream>()));
        }
Example #2
0
        public void PerformExecution_GivenNoPaths_ShouldThrowException()
        {
            //---------------Set up test pack-------------------
            var mockExecutor  = new Mock <IDropboxSingleExecutor <IDropboxResult> >();
            var clientWrapper = new Mock <IDropboxClientWrapper>();

            mockExecutor.Setup(executor => executor.ExecuteTask(TestConstant.DropboxClientInstance.Value))
            .Returns(new DropboxUploadSuccessResult(TestConstant.FileMetadataInstance.Value));
            var dsfDropBoxUploadAcivtityMock = new DsfDropBoxUploadActivityMock(mockExecutor.Object, clientWrapper.Object)
            {
                IsUplodValidSuccess = true
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dsfDropBoxUploadAcivtityMock);
            //---------------Execute Test ----------------------
            dsfDropBoxUploadAcivtityMock.PerfomBaseExecution(new Dictionary <string, string>());
            //---------------Test Result -----------------------
            Assert.Fail("Exception Not Throw");
        }