Ejemplo n.º 1
0
        public void DsfDropBoxDeleteActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            var uniqueId       = Guid.NewGuid();
            var selectedSource = new MockOAuthSource(uniqueId);

            //------------Setup for test--------------------------
            var dropBoxDeleteActivity = new DsfDropBoxDeleteActivity {
                SelectedSource = selectedSource, DeletePath = "Path", Result = "Deleted"
            };
            //------------Execute Test---------------------------
            var stateItems = dropBoxDeleteActivity.GetState();

            Assert.AreEqual(3, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "SelectedSource.ResourceID",
                    Type  = StateVariable.StateType.Input,
                    Value = uniqueId.ToString()
                },
                new StateVariable
                {
                    Name  = "DeletePath",
                    Type  = StateVariable.StateType.Input,
                    Value = "Path"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = "Deleted"
                }
            };

            var iter = dropBoxDeleteActivity.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
        public void DsfDropBoxUploadActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            var uniqueId       = Guid.NewGuid();
            var selectedSource = new MockOAuthSource(uniqueId);

            var mockDropboxClient        = new Mock <IDropboxClient>();
            var mockDropboxClientFactory = new Mock <IDropboxClientFactory>();

            mockDropboxClientFactory.Setup(o => o.New(It.IsAny <string>(), It.IsAny <HttpClient>())).Returns(mockDropboxClient.Object);

            //------------Setup for test--------------------------
            using (var dropBoxUploadActivity = new TestDsfDropBoxUploadActivity(mockDropboxClientFactory.Object)
            {
                SelectedSource = selectedSource,
                FromPath = "Path_From",
                ToPath = "Path_To",
                OverWriteMode = false,
                Result = "Uploaded"
            })
            {
                dropBoxUploadActivity.SetupDropboxClient("");

                //------------Execute Test---------------------------
                var stateItems = dropBoxUploadActivity.GetState();
                Assert.AreEqual(5, stateItems.Count());

                var expectedResults = new[]
                {
                    new StateVariable
                    {
                        Name  = "SelectedSource.ResourceID",
                        Type  = StateVariable.StateType.Input,
                        Value = uniqueId.ToString()
                    },
                    new StateVariable
                    {
                        Name  = "FromPath",
                        Type  = StateVariable.StateType.Input,
                        Value = "Path_From"
                    },
                    new StateVariable
                    {
                        Name  = "ToPath",
                        Type  = StateVariable.StateType.Input,
                        Value = "Path_To"
                    },
                    new StateVariable
                    {
                        Name  = "OverWriteMode",
                        Type  = StateVariable.StateType.Input,
                        Value = "False"
                    },
                    new StateVariable
                    {
                        Name  = "Result",
                        Type  = StateVariable.StateType.Output,
                        Value = "Uploaded"
                    }
                };

                var iter = dropBoxUploadActivity.GetState().Select(
                    (item, index) => new
                {
                    value       = item,
                    expectValue = expectedResults[index]
                }
                    );

                //------------Assert Results-------------------------
                foreach (var entry in iter)
                {
                    Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                    Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                    Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
                }
            }
        }
        public void DsfDropboxFileListActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            var uniqueId       = Guid.NewGuid();
            var selectedSource = new MockOAuthSource(uniqueId);

            //------------Setup for test--------------------------
            var dropboxFileListActivity = new DsfDropboxFileListActivity
            {
                SelectedSource            = selectedSource,
                ToPath                    = "Path_To",
                IsFilesSelected           = false,
                IsFoldersSelected         = false,
                IsFilesAndFoldersSelected = false,
                IsRecursive               = false,
                Result                    = "List_Complete"
            };
            //------------Execute Test---------------------------
            var stateItems = dropboxFileListActivity.GetState();

            Assert.AreEqual(7, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "SelectedSource.ResourceID",
                    Type  = StateVariable.StateType.Input,
                    Value = uniqueId.ToString()
                },
                new StateVariable
                {
                    Name  = "ToPath",
                    Type  = StateVariable.StateType.Input,
                    Value = "Path_To"
                },
                new StateVariable
                {
                    Name  = "IsFilesSelected",
                    Type  = StateVariable.StateType.Input,
                    Value = "False"
                },
                new StateVariable
                {
                    Name  = "IsFoldersSelected",
                    Type  = StateVariable.StateType.Input,
                    Value = "False"
                },
                new StateVariable
                {
                    Name  = "IsFilesAndFoldersSelected",
                    Type  = StateVariable.StateType.Input,
                    Value = "False"
                },
                new StateVariable
                {
                    Name  = "IsRecursive",
                    Type  = StateVariable.StateType.Input,
                    Value = "False"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = "List_Complete"
                }
            };

            var iter = dropboxFileListActivity.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }