public void DsfDotNetMultiAssignObjectActivity_ToNewRecordset_DebugModeAddsDebugItems()
        {
            var env = new ExecutionEnvironment();

            env.AssignJson(new AssignValue("[[@names(1).Name]]", "Mary"), 0);
            env.AssignJson(new AssignValue("[[@names(2).Name]]", "Jane"), 0);
            env.Assign("[[list().name]]", "asdf", 0);

            var data = new Mock <IDSFDataObject>();

            data.Setup(o => o.Environment).Returns(() => env);
            data.Setup(o => o.IsDebugMode()).Returns(() => true);

            var ob = new DsfDotNetMultiAssignObjectActivity
            {
                FieldsCollection = new List <AssignObjectDTO>
                {
                    new AssignObjectDTO("[[list().name]]", "[[list().name]]", 0)
                }
            };

            ob.Execute(data.Object, 0);

            var a = ob.GetDebugOutputs(env, 0);

            Assert.AreEqual("asdf", a[0].ResultsList[1].Value);
            Assert.AreEqual("[[list(1).name]]", a[0].ResultsList[1].Variable);
        }
        public void DsfDotNetMultiAssignObjectActivity_WhenSameFieldCollectionData_ShouldBeEqual()
        {
            var fieldCollection = new List <AssignObjectDTO>();

            fieldCollection.Add(new AssignObjectDTO("[[a]]", "12", fieldCollection.Count));
            var activity1 = new DsfDotNetMultiAssignObjectActivity {
                OutputMapping = null, FieldsCollection = fieldCollection
            };

            var fieldCollection2 = new List <AssignObjectDTO>();

            fieldCollection2.Add(new AssignObjectDTO("[[a]]", "12", fieldCollection2.Count));
            var activity2 = new DsfDotNetMultiAssignObjectActivity
            {
                UniqueID         = activity1.UniqueID, // simulate this assign being from a copied/cloned workflow
                OutputMapping    = null,
                FieldsCollection = fieldCollection2
            };

            Assert.IsTrue(activity1.Equals(activity2));
            activity2.CreateBookmark = true;
            Assert.IsFalse(activity1.Equals(activity2));
            activity2.CreateBookmark       = false;
            activity2.UpdateAllOccurrences = true;
            Assert.IsFalse(activity1.Equals(activity2));
            activity2.UpdateAllOccurrences = false;
            Assert.IsTrue(activity1.Equals(activity2));
        }
        public void DsfMultiAssignObjectActivity_UpdateForEachOutputs_WhenContainsMatchingStar_UpdateSuccessful()
        {
            //------------Setup for test--------------------------
            var fieldsCollection = new List <AssignObjectDTO>
            {
                new AssignObjectDTO("[[@Pet.Owner(1).Name]]", "Bob", 1),
            };

            var act = new DsfDotNetMultiAssignObjectActivity {
                FieldsCollection = fieldsCollection
            };

            //------------Execute Test---------------------------

            act.UpdateForEachOutputs(new List <Tuple <string, string> >
            {
                new Tuple <string, string>("[[@Pet.Owner(*).Name]]", "[[@Pet.Owner(1).Name]]"),
            });

            //------------Assert Results-------------------------

            var collection = act.FieldsCollection;

            Assert.AreEqual("Bob", collection[0].FieldValue);
        }
        public void DsfMultiAssignObjectActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt()
        {
            //------------Setup for test--------------------------
            var fieldCollection = new ObservableCollection <AssignObjectDTO>();

            fieldCollection.Add(new AssignObjectDTO("[[@test.value1]]", "somevalue", fieldCollection.Count));
            var act = new DsfDotNetMultiAssignObjectActivity {
                OutputMapping = null, FieldsCollection = fieldCollection
            };
            //------------Execute Test---------------------------
            var outputs = act.GetOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, outputs.Count);
            Assert.AreEqual("[[@test.value1]]", outputs[0]);
        }
        public void DsfDotNetMultiAssignObjectActivity_WhenDifferentFieldCollectionData_SHouldBeNotEqual()
        {
            var fieldCollection = new List <AssignObjectDTO>();

            fieldCollection.Add(new AssignObjectDTO("[[a]]", "12", fieldCollection.Count));
            var activity1 = new DsfDotNetMultiAssignObjectActivity {
                OutputMapping = null, FieldsCollection = fieldCollection
            };

            var fieldCollection2 = new List <AssignObjectDTO>();

            fieldCollection2.Add(new AssignObjectDTO("[[a]]", "111", fieldCollection2.Count));
            var activity2 = new DsfDotNetMultiAssignObjectActivity
            {
                UniqueID         = activity1.UniqueID, // simulate this assign being from a copied/cloned workflow
                OutputMapping    = null,
                FieldsCollection = fieldCollection2
            };

            Assert.IsFalse(activity1.Equals(activity2));
        }
        public void DsfMultiAssignActivity_GetForEachOutputs_Normal_UpdateSuccessful()
        {
            //------------Setup for test--------------------------
            var fieldsCollection = new List <AssignObjectDTO>
            {
                new AssignObjectDTO("[[@Pet.Name]]", "[[result]]", 1),
            };

            var act = new DsfDotNetMultiAssignObjectActivity {
                FieldsCollection = fieldsCollection
            };

            //------------Execute Test---------------------------

            var inputs = act.GetForEachOutputs();

            //------------Assert Results-------------------------

            Assert.AreEqual("[[@Pet.Name]]", inputs[0].Value);
            Assert.AreEqual("[[result]]", inputs[0].Name);
        }
        public void DsfDotnetMultiAssignObject_GetState_Returns_Input_And_Outputs()
        {
            var fieldCollection = new ObservableCollection <AssignObjectDTO>
            {
                new AssignObjectDTO("[[test.value1]]", "[[test..value2]]", 1)
            };
            var act = new DsfDotNetMultiAssignObjectActivity
            {
                FieldsCollection = fieldCollection
            };
            var stateItems = act.GetState();

            Assert.AreEqual(1, stateItems.Count());
            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "Fields Collection",
                    Type  = StateVariable.StateType.InputOutput,
                    Value = ActivityHelper.GetSerializedStateValueFromCollection(fieldCollection)
                }
            };

            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);
            }
        }