Example #1
0
        public void Copy_Construct_Object_Must_Be_OfType_IDestinationUsernamePassword()
        {
            var pathCopy = new DsfPathCopy();
            IDestinationUsernamePassword password = pathCopy;

            Assert.IsNotNull(password);
        }
Example #2
0
        protected override void BuildDataList()
        {
            BuildShapeAndTestData();

            var copy = new DsfPathCopy
            {
                InputPath           = scenarioContext.Get <string>(CommonSteps.SourceHolder),
                Username            = scenarioContext.Get <string>(CommonSteps.SourceUsernameHolder),
                Password            = scenarioContext.Get <string>(CommonSteps.SourcePasswordHolder),
                OutputPath          = scenarioContext.Get <string>(CommonSteps.DestinationHolder),
                DestinationUsername = scenarioContext.Get <string>(CommonSteps.DestinationUsernameHolder),
                DestinationPassword = scenarioContext.Get <string>(CommonSteps.DestinationPasswordHolder),
                Overwrite           = scenarioContext.Get <bool>(CommonSteps.OverwriteHolder),
                Result                    = scenarioContext.Get <string>(CommonSteps.ResultVariableHolder),
                PrivateKeyFile            = scenarioContext.Get <string>(CommonSteps.SourcePrivatePublicKeyFile),
                DestinationPrivateKeyFile = scenarioContext.Get <string>(CommonSteps.DestinationPrivateKeyFile)
            };

            TestStartNode = new FlowStep
            {
                Action = copy
            };

            scenarioContext.Add("activity", copy);
        }
Example #3
0
        public void Copy_Execute_Workflow_SourceFile_And_DestinationFile_Has_Separate_Passwords_Both_Passwords_Are_Sent_To_OperationBroker()
        {
            var fileNames = new List <string>();

            fileNames.Add(Path.Combine(TestContext.TestRunDirectory, Guid.NewGuid() + ".txt"));

            foreach (string fileName in fileNames)
            {
                File.WriteAllText(fileName, "TestData");
            }

            CreateDataListWithRecsetAndCreateShape(fileNames, "FileNames", "Name", out string dataListShape, out string dataListWithData);

            var activityOperationBrokerMock = new ActivityOperationBrokerMock();

            var act = new DsfPathCopy
            {
                InputPath           = @"c:\OldFile.txt",
                OutputPath          = Path.Combine(TestContext.TestRunDirectory, "NewName.txt"),
                Result              = "[[res]]",
                DestinationUsername = "******",
                DestinationPassword = "******",
                Username            = "******",
                Password            = "******",
                GetOperationBroker  = () => activityOperationBrokerMock
            };

            CheckPathOperationActivityDebugInputOutput(act, dataListShape,
                                                       dataListWithData, out List <DebugItem> inRes, out List <DebugItem> outRes);

            Assert.AreEqual(activityOperationBrokerMock.Destination.IOPath.Password, "destPWord");
            Assert.AreEqual(activityOperationBrokerMock.Destination.IOPath.Username, "destUName");
            Assert.AreEqual(activityOperationBrokerMock.Source.IOPath.Password, "pWord");
            Assert.AreEqual(activityOperationBrokerMock.Source.IOPath.Username, "uName");
        }
Example #4
0
        public void PathCopyActivity_GetOutputs_Expected_One_Output()
        {
            DsfPathCopy testAct = new DsfPathCopy();

            IBinaryDataList outputs = testAct.GetOutputs();

            Assert.IsTrue(outputs.FetchAllEntries().Count == 1);
        }
Example #5
0
        public void PathCopyActivity_GetInputs_Expected_Six_Input()
        {
            DsfPathCopy testAct = new DsfPathCopy();

            IBinaryDataList inputs = testAct.GetInputs();

            Assert.IsTrue(inputs.FetchAllEntries().Count == 8);
        }
Example #6
0
        public void DsfPathCopy_UpdateForEachOutputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            var          newGuid = Guid.NewGuid();
            const string result  = "[[CompanyName]]";
            var          act     = new DsfPathCopy {
                InputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt"), OutputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt"), Result = result
            };

            act.UpdateForEachOutputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
Example #7
0
        public void DsfPathCopy_UpdateForEachInputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            var newGuid    = Guid.NewGuid();
            var inputPath  = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt");
            var outputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt");
            var act        = new DsfPathCopy {
                InputPath = inputPath, OutputPath = outputPath, Result = "[[CompanyName]]"
            };

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(inputPath, act.InputPath);
            Assert.AreEqual(outputPath, act.OutputPath);
        }
Example #8
0
        public void DsfPathCopy_GetForEachOutputs_WhenHasResult_ReturnsOutputList()
        {
            //------------Setup for test--------------------------
            var          newGuid = Guid.NewGuid();
            const string result  = "[[CompanyName]]";
            var          act     = new DsfPathCopy {
                InputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt"), OutputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt"), Result = result
            };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, dsfForEachItems.Count);
            Assert.AreEqual(result, dsfForEachItems[0].Name);
            Assert.AreEqual(result, dsfForEachItems[0].Value);
        }
Example #9
0
        public void DsfPathCopy_UpdateForEachOutputs_1Updates_UpdateResult()
        {
            //------------Setup for test--------------------------
            var newGuid    = Guid.NewGuid();
            var inputPath  = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt");
            var outputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt");
            var act        = new DsfPathCopy {
                InputPath = inputPath, OutputPath = outputPath, Result = "[[CompanyName]]"
            };

            var tuple1 = new Tuple <string, string>("[[CompanyName]]", "Test");

            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List <Tuple <string, string> > {
                tuple1
            });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test", act.Result);
        }
Example #10
0
        public void DsfPathCopy_UpdateForEachOutputs_MoreThan1Updates_DoesNothing()
        {
            //------------Setup for test--------------------------
            var          newGuid = Guid.NewGuid();
            const string result  = "[[CompanyName]]";
            var          act     = new DsfPathCopy {
                InputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt"), OutputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt"), Result = result
            };

            var tuple1 = new Tuple <string, string>("Test", "Test");
            var tuple2 = new Tuple <string, string>("Test2", "Test2");

            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List <Tuple <string, string> > {
                tuple1, tuple2
            });
            //------------Assert Results-------------------------
            Assert.AreEqual(result, act.Result);
        }
Example #11
0
        public void DsfPathCopy_GetForEachInputs_WhenHasExpression_ReturnsInputList()
        {
            //------------Setup for test--------------------------
            var newGuid    = Guid.NewGuid();
            var inputPath  = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]].txt");
            var outputPath = string.Concat(TestContext.TestRunDirectory, "\\", newGuid + "[[CompanyName]]2.txt");
            var act        = new DsfPathCopy {
                InputPath = inputPath, OutputPath = outputPath, Result = "[[CompanyName]]"
            };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachInputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(2, dsfForEachItems.Count);
            Assert.AreEqual(inputPath, dsfForEachItems[0].Name);
            Assert.AreEqual(inputPath, dsfForEachItems[0].Value);
            Assert.AreEqual(outputPath, dsfForEachItems[1].Name);
            Assert.AreEqual(outputPath, dsfForEachItems[1].Value);
        }
        public void GetActivityFieldsOffDsfPathCopyActivityExpectedAllFindMissingFieldsToBeReturned()
        {
            DsfPathCopy activity = new DsfPathCopy();

            activity.InputPath           = "[[InputPath]]";
            activity.OutputPath          = "[[OutputPath]]";
            activity.Password            = "******";
            activity.Username            = "******";
            activity.DestinationPassword = "******";
            activity.DestinationUsername = "******";
            activity.Result = "[[Result]]";
            Dev2FindMissingStrategyFactory fac      = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy           strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            List <string> actual   = strategy.GetActivityFields(activity);
            List <string> expected = new List <string> {
                "[[InputPath]]", "[[OutputPath]]", "[[DestUsername]]", "[[DestPassword]]", "[[Password]]", "[[Username]]", "[[Result]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
        public void Dev2FindMissingStrategyFactory_GetActivityFieldsOff_DsfPathCopy_Activity_ExpectAllFindMissingFieldsToBeReturned()
        {
            var activity = new DsfPathCopy
            {
                InputPath                 = "[[InputPath]]",
                OutputPath                = "[[OutputPath]]",
                Password                  = "******",
                PrivateKeyFile            = "[[KeyFile]]",
                Username                  = "******",
                DestinationPassword       = "******",
                DestinationUsername       = "******",
                DestinationPrivateKeyFile = "[[DestKeyFile]]",
                Result = "[[Result]]"
            };
            var fac      = new Dev2FindMissingStrategyFactory();
            var strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            var actual   = strategy.GetActivityFields(activity);
            var expected = new List <string> {
                "[[InputPath]]", "[[OutputPath]]", "[[DestUsername]]", "[[DestKeyFile]]", "[[DestPassword]]", "[[Password]]", "[[Username]]", "[[KeyFile]]", "[[Result]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Example #14
0
        protected override void BuildDataList()
        {
            BuildShapeAndTestData();


            var create = new DsfPathCopy();

            create.InputPath           = ScenarioContext.Current.Get <string>(CommonSteps.SourceHolder);
            create.Username            = ScenarioContext.Current.Get <string>(CommonSteps.SourceUsernameHolder);
            create.Password            = ScenarioContext.Current.Get <string>(CommonSteps.SourcePasswordHolder);
            create.OutputPath          = ScenarioContext.Current.Get <string>(CommonSteps.DestinationHolder);
            create.DestinationUsername = ScenarioContext.Current.Get <string>(CommonSteps.DestinationUsernameHolder);
            create.DestinationPassword = ScenarioContext.Current.Get <string>(CommonSteps.DestinationPasswordHolder);
            create.Overwrite           = ScenarioContext.Current.Get <bool>(CommonSteps.OverwriteHolder);
            create.Result = ScenarioContext.Current.Get <string>(CommonSteps.ResultVariableHolder);

            TestStartNode = new FlowStep
            {
                Action = create
            };

            ScenarioContext.Current.Add("activity", create);
        }
Example #15
0
        public void DsfPathCopy_GetState_ReturnsStateVariable()
        {
            var act = new DsfPathCopy
            {
                InputPath                 = "/inpath",
                Username                  = "******",
                Password                  = "******",
                PrivateKeyFile            = "/path/to/secret",
                OutputPath                = "/outpath",
                DestinationUsername       = "******",
                DestinationPassword       = "******",
                DestinationPrivateKeyFile = "/dest/path/to/secret",
                Overwrite                 = true,
                Result = "[[result]]"
            };

            //------------Execute Test---------------------------
            var stateItems = act.GetState();

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

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "InputPath",
                    Value = "/inpath",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "Username",
                    Value = "myuser",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "PrivateKeyFile",
                    Value = "/path/to/secret",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "OutputPath",
                    Value = "/outpath",
                    Type  = StateVariable.StateType.Output
                },
                new StateVariable
                {
                    Name  = "DestinationUsername",
                    Value = "destmyuser",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "DestinationPrivateKeyFile",
                    Value = "/dest/path/to/secret",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "Overwrite",
                    Value = "True",
                    Type  = StateVariable.StateType.Input
                },
                new StateVariable
                {
                    Name  = "Result",
                    Value = "[[result]]",
                    Type  = StateVariable.StateType.Output
                }
            };

            var iter = act.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);
            }
        }