Exemplo n.º 1
0
        static ModelItem CreateNullToModelItem()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To = null,
            };

            return(ModelItemUtils.CreateModelItem(activity));
        }
Exemplo n.º 2
0
        static ModelItem CreateModelItem()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To      = "*****@*****.**",
                Subject = "Test Exchange",
                Body    = "Test email from exchange"
            };

            return(ModelItemUtils.CreateModelItem(activity));
        }
Exemplo n.º 3
0
        static ModelItem CreateFullToModelItem()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "test",
                Cc          = "test",
                Body        = "test",
                Bcc         = "test",
                Attachments = "test"
            };

            return(ModelItemUtils.CreateModelItem(activity));
        }
Exemplo n.º 4
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_BccIsNotValidEmailAddress_DoesHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "",
                Cc          = "",
                Bcc         = "user2#mydomain.com",
                Subject     = "The Subject",
                Attachments = "",
                Body        = "The body",
            };

            ValidateThis(activity, "'Bcc' contains an invalid email address", ExchangeNewEmailDesignerViewModel.IsBccFocusedProperty);
        }
Exemplo n.º 5
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_SubjectIsEmpyAndBodyIsNotEmpty_DoesNotHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "*****@*****.**",
                Cc          = "",
                Bcc         = "",
                Subject     = "",
                Attachments = "",
                Body        = "The Body",
            };

            ValidateThis(activity);
        }
Exemplo n.º 6
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_SubjectAndBodyIsEmpty_DoesHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "*****@*****.**",
                Cc          = "",
                Bcc         = "",
                Subject     = "",
                Attachments = "",
                Body        = "",
            };

            ValidateThis(activity, "Please supply at least one of the following: 'Subject' or 'Body'", ExchangeNewEmailDesignerViewModel.IsSubjectFocusedProperty);
        }
Exemplo n.º 7
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_RecipientsIsEmpty_DoesHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "",
                Cc          = "",
                Bcc         = "",
                Subject     = "The Subject",
                Attachments = "",
                Body        = "The body",
            };

            ValidateThis(activity, "Please supply at least one of the following: 'To', 'Cc' or 'Bcc'", ExchangeNewEmailDesignerViewModel.IsToFocusedProperty);
        }
Exemplo n.º 8
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_AttachmentsIsNotValidFileName_DoesHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "",
                Cc          = "",
                Bcc         = "*****@*****.**",
                Subject     = "The Subject",
                Attachments = "c:\\logs",
                Body        = "The body",
            };

            ValidateThis(activity, "'Attachments' contains an invalid file name", ExchangeNewEmailDesignerViewModel.IsAttachmentsFocusedProperty);
        }
Exemplo n.º 9
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_AttachmentsIsValidExpression_DoesNotHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "",
                Cc          = "",
                Bcc         = "*****@*****.**",
                Subject     = "The Subject",
                Attachments = "[[h]]",
                Body        = "The body",
            };

            ValidateThis(activity);
        }
Exemplo n.º 10
0
        public void ExchangeNewEmailDesignerViewModel_ValidateThis_AttachmentsIsNotValidExpression_DoesHaveErrors()
        {
            var activity = new DsfExchangeEmailNewActivity
            {
                To          = "",
                Cc          = "",
                Bcc         = "*****@*****.**",
                Subject     = "The Subject",
                Attachments = "h]]",
                Body        = "The body",
            };

            ValidateThis(activity, Warewolf.Resource.Errors.ErrorResource.EmailAttachmentsInvalidExpressionErrorTest, ExchangeNewEmailDesignerViewModel.IsAttachmentsFocusedProperty);
        }
Exemplo n.º 11
0
        public void DsfExchangeEmailNewActivity_InvalidRuntimeSource()
        {
            var env      = new ExecutionEnvironment();
            var dataMock = new Mock <IDSFDataObject>();

            dataMock.Setup(o => o.Environment).Returns(() => env);

            var act = new DsfExchangeEmailNewActivity
            {
                SavedSource = new Mock <IExchangeSource>().Object
            };

            act.Execute(dataMock.Object, 0);

            Assert.AreEqual(1, env.Errors.Count);
            Assert.AreEqual("Invalid Email Source", env.FetchErrors());
        }
        public void Null_Objects_Not_Equal_Same_Object_Equal()
        {
            //---------------Set up test pack-------------------
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
            };
            Object other = exchangeEmailActivity;

            //---------------Assert Precondition----------------
            Assert.IsFalse(exchangeEmailActivity.Equals(null));
            Assert.IsFalse(other.Equals(null));
            Assert.IsFalse(other.Equals(1));
            Assert.IsFalse(exchangeEmailActivity.Equals(1));
            //---------------Execute Test ----------------------

            Assert.IsTrue(exchangeEmailActivity.Equals(other));
            Assert.IsTrue(exchangeEmailActivity.Equals(exchangeEmailActivity));
        }
Exemplo n.º 13
0
        public void Body_Different_Object_Is_Not_Equal_CaseSensitive()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Body = "AAA"
            };
            var exchangeEmailActivity1 = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Body = "aaa"
            };

            //---------------Assert DsfExchangeEmailNewActivity----------------
            Assert.IsNotNull(exchangeEmailActivity);
            //---------------Execute Test ----------------------
            var @equals = exchangeEmailActivity.Equals(exchangeEmailActivity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
Exemplo n.º 14
0
        public void Body_Same_Object_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Body = "a"
            };
            var exchangeEmailActivity1 = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Body = "a"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(exchangeEmailActivity);
            //---------------Execute Test ----------------------
            var @equals = exchangeEmailActivity.Equals(exchangeEmailActivity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
Exemplo n.º 15
0
        public void Attachments_Different_Object_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Attachments = "A"
            };
            var exchangeEmailActivity1 = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Attachments = "ass"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(exchangeEmailActivity);
            //---------------Execute Test ----------------------
            var @equals = exchangeEmailActivity.Equals(exchangeEmailActivity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(equals);
        }
Exemplo n.º 16
0
        public void UniqueIDEquals_EmptyDropBoxDeleteActivities_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId
            };
            var exchangeEmailActivity1 = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(exchangeEmailActivity);
            //---------------Execute Test ----------------------
            var @equals = exchangeEmailActivity.Equals(exchangeEmailActivity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
Exemplo n.º 17
0
        public void SavedSource_Same_Object_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var exchangeEmailActivity = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Result = "A"
            };
            var exchangeEmailActivity1 = new DsfExchangeEmailNewActivity {
                UniqueID = uniqueId, Result = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(exchangeEmailActivity.Equals(exchangeEmailActivity1));
            //---------------Execute Test ----------------------
            exchangeEmailActivity.SavedSource  = new ExchangeSourceDefinition();
            exchangeEmailActivity1.SavedSource = new ExchangeSourceDefinition();
            var @equals = exchangeEmailActivity.Equals(exchangeEmailActivity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(equals);
        }
Exemplo n.º 18
0
        void ValidateThis(DsfExchangeEmailNewActivity activity, string expectedErrorMessage = null, DependencyProperty isFocusedProperty = null, bool setSelectedEmailSource = true)
        {
            var sources = CreateEmailSources(1);

            if (setSelectedEmailSource)
            {
                activity.SavedSource = sources[0];
            }

            var modelItem = ModelItemUtils.CreateModelItem(activity);

            var eventPublisher = new Mock <IEventAggregator>();

            eventPublisher.Setup(p => p.Publish(It.IsAny <FileChooserMessage>())).Verifiable();
            var mockShellViewModel = new Mock <IShellViewModel>();

            var viewModel = CreateViewModel(mockShellViewModel.Object, modelItem, eventPublisher.Object);

            //------------Execute Test---------------------------
            viewModel.Validate();

            //------------Assert Results-------------------------
            if (string.IsNullOrEmpty(expectedErrorMessage))
            {
                Assert.IsNull(viewModel.Errors);
            }
            else
            {
                Assert.IsNotNull(viewModel.Errors);
                Assert.AreEqual(1, viewModel.Errors.Count);
                StringAssert.Contains(viewModel.Errors[0].Message, expectedErrorMessage);

                viewModel.Errors[0].Do();
                var isFocused = isFocusedProperty != null && (bool)viewModel.GetValue(isFocusedProperty);
                Assert.IsTrue(isFocused);
            }
        }
Exemplo n.º 19
0
        public void DsfExchangeEmailNewActivity_UpdateForEachInputs_ExpectReplacedValues()
        {
            var act = new DsfExchangeEmailNewActivity
            {
                To          = "ToValue1",
                Cc          = "CcValue1",
                Bcc         = "BccValue1",
                Subject     = "SubjectValue1",
                Attachments = "AttachmentsValue1",
                Body        = "BodyValue1",
                SavedSource = new Mock <IExchangeSource>().Object
            };
            List <Tuple <string, string> > updates = null;

            // test that null input is okay
            act.UpdateForEachInputs(updates);

            // test all headers can be updated
            updates = new List <Tuple <string, string> >
            {
                new Tuple <string, string>("ToValue1", "ToValue2"),
                new Tuple <string, string>("CcValue1", "CcValue2"),
                new Tuple <string, string>("BccValue1", "BccValue2"),
                new Tuple <string, string>("SubjectValue1", "SubjectValue2"),
                new Tuple <string, string>("AttachmentsValue1", "AttachmentsValue2"),
                new Tuple <string, string>("BodyValue1", "BodyValue2")
            };
            act.UpdateForEachInputs(updates);

            Assert.AreEqual("ToValue2", act.To);
            Assert.AreEqual("CcValue2", act.Cc);
            Assert.AreEqual("BccValue2", act.Bcc);
            Assert.AreEqual("SubjectValue2", act.Subject);
            Assert.AreEqual("AttachmentsValue2", act.Attachments);
            Assert.AreEqual("BodyValue2", act.Body);
        }
Exemplo n.º 20
0
        protected override void BuildDataList()
        {
            scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList);

            if (variableList == null)
            {
                variableList = new List <Tuple <string, string> >();
                scenarioContext.Add("variableList", variableList);
            }

            variableList.Add(new Tuple <string, string>(ResultVariable, ""));
            BuildShapeAndTestData();

            scenarioContext.TryGetValue("body", out string body);
            scenarioContext.TryGetValue("subject", out string subject);
            scenarioContext.TryGetValue("password", out string password);
            scenarioContext.TryGetValue("simulationOutput", out string simulationOutput);
            scenarioContext.TryGetValue("to", out string to);
            scenarioContext.TryGetValue("isHtml", out string isHtml);

            var server = SimpleSmtpServer.Start(25);

            scenarioContext.Add("server", server);

            var resourceName        = Guid.NewGuid();
            var resourceID          = Guid.NewGuid();
            var selectedEmailSource = new ExchangeSourceDefinition
            {
                AutoDiscoverUrl = "https://outlook.office365.com/EWS/Exchange.asmx",
                UserName        = "******",
                Password        = "******",
                ResourceName    = resourceName.ToString(),
                ResourceID      = resourceID
            };


            var emailSource = new ExchangeSource
            {
                AutoDiscoverUrl = "https://outlook.office365.com/EWS/Exchange.asmx",
                UserName        = "******",
                Password        = "******",
                ResourceName    = resourceName.ToString(),
                ResourceID      = resourceID
            };

            ResourceCatalog.Instance.SaveResource(Guid.Empty, emailSource, "");
            var emailSender = new Mock <IDev2EmailSender>();

            var eR = new ErrorResultTO();

            emailSender
            .Setup(sender => sender.SendEmail(It.IsAny <IExchange>(), It.IsAny <IWarewolfListIterator>(), It.IsAny <IWarewolfIterator>(), It.IsAny <IWarewolfIterator>(), It.IsAny <IWarewolfIterator>(), It.IsAny <IWarewolfIterator>(), It.IsAny <IWarewolfIterator>(), It.IsAny <IWarewolfIterator>(), out eR, It.IsAny <bool>()))
            .Returns("Success")
            .Callback(new myDelegate((IExchange source, IWarewolfListIterator listIterator, IWarewolfIterator i1, IWarewolfIterator i2, IWarewolfIterator i3, IWarewolfIterator i4, IWarewolfIterator i5, IWarewolfIterator i6, out ErrorResultTO errors, bool _isHtml) =>
            {
                listIterator.FetchNextValue(i1);
                listIterator.FetchNextValue(i2);
                listIterator.FetchNextValue(i3);
                listIterator.FetchNextValue(i4);
                listIterator.FetchNextValue(i5);
                listIterator.FetchNextValue(i6);
                isHtml = _isHtml ? "true" : "false";
                errors = null;
            }));
            var sendEmail = new DsfExchangeEmailNewActivity(emailSender.Object)
            {
                Result      = ResultVariable,
                Body        = string.IsNullOrEmpty(body) ? "" : body,
                Subject     = string.IsNullOrEmpty(subject) ? "" : subject,
                To          = string.IsNullOrEmpty(to) ? "" : to,
                SavedSource = selectedEmailSource,
                Cc          = string.Empty,
                Bcc         = String.Empty,
                Attachments = String.Empty
            };

            if (isHtml == "true")
            {
                sendEmail.IsHtml = true;
            }
            else
            {
                sendEmail.IsHtml = false;
            }

            TestStartNode = new FlowStep
            {
                Action = sendEmail
            };
            scenarioContext.Add("activity", sendEmail);
        }
Exemplo n.º 21
0
        public void DsfExchangeEmailNewActivity_GetState_ReturnsStateVariable()
        {
            //------------Setup for test--------------------------
            var uniqueId           = Guid.NewGuid();
            var mockExchangeSource = new Mock <IExchangeSource>();

            mockExchangeSource.Setup(source => source.ResourceID).Returns(uniqueId);

            var expectedSavedSource = mockExchangeSource.Object;
            var expectedTo          = "*****@*****.**";
            var expectedCc          = "*****@*****.**";
            var expectedBcc         = "*****@*****.**";
            var expectedSubject     = "test Email";
            var expectedAttachments = "att_1;att_2;att_3";
            var expectedBody        = "Email Body";
            var expectedResult      = "[[res]]";

            var act = new DsfExchangeEmailNewActivity
            {
                SavedSource = expectedSavedSource,
                To          = expectedTo,
                Cc          = expectedCc,
                Bcc         = expectedBcc,
                Subject     = expectedSubject,
                Attachments = expectedAttachments,
                IsHtml      = true,
                Body        = expectedBody,
                Result      = expectedResult
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

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

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "SavedSource.ResourceID",
                    Type  = StateVariable.StateType.Input,
                    Value = uniqueId.ToString()
                },
                new StateVariable
                {
                    Name  = "To",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedTo
                },
                new StateVariable
                {
                    Name  = "Cc",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedCc
                },
                new StateVariable
                {
                    Name  = "Bcc",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedBcc
                },
                new StateVariable
                {
                    Name  = "Subject",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedSubject
                },
                new StateVariable
                {
                    Name  = "Attachments",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedAttachments
                },
                new StateVariable
                {
                    Name  = "IsHtml",
                    Type  = StateVariable.StateType.Input,
                    Value = "True"
                },
                new StateVariable
                {
                    Name  = "Body",
                    Type  = StateVariable.StateType.Input,
                    Value = expectedBody
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = expectedResult
                }
            };

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