void Verify_Constructor_DoesNotAutoCopyEmailSourceUserNameIntoFromAccount(string to)
        {
            //------------Setup for test--------------------------
            var activity = new DsfExchangeEmailActivity()
            {
                To = to
            };

            var emailSource = new ExchangeSourceDefinition
            {
                UserName   = "******",
                Password   = "******",
                ResourceID = Guid.NewGuid()
            };
            var modelItem      = ModelItemUtils.CreateModelItem(activity);
            var eventPublisher = new Mock <IEventAggregator>();
            var viewModel      = CreateViewModel(modelItem, eventPublisher.Object);

            //------------Execute Test---------------------------
            viewModel.SourceRegion.SelectedSource = emailSource;

            //------------Assert Results-------------------------
            var toReceipient = modelItem.GetProperty <string>("To");

            Assert.AreEqual(to, toReceipient);
        }
        public ManageExchangeSourceViewModel GetViewModelWithSource()
        {
            var mock = new Mock <IManageExchangeSourceModel>();
            var exchangeSourceDefinition = new ExchangeSourceDefinition()
            {
                AutoDiscoverUrl = "test",
                Password        = "******",
                UserName        = "******",
                Path            = "test",
                ResourceName    = "test exchange",
                Type            = enSourceType.ExchangeSource,
            };

            mock.Setup(model => model.FetchSource(It.IsAny <Guid>()))
            .Returns(exchangeSourceDefinition);
            return(new ManageExchangeSourceViewModel(mock.Object, new Mock <IEventAggregator>().Object, exchangeSourceDefinition, new SynchronousAsyncWorker())
            {
                Name = "Exchange Source",
                AutoDiscoverUrl = "test Url",
                EmailTo = "test",
                IsActive = true,
                ResourceName = "Exchange Soure",
                UserName = "******",
                Password = "******",
                Timeout = 10000,
                HeaderText = "Exchange Source",
                TestPassed = false,
                TestFailed = false,
                TestMessage = "testing",
                EnableSend = true,
                Testing = false,
            });
        }
        public void ExchangeSourceDefinition_GetHashCode_Expect_Zero()
        {
            var exchangeSourceDefinition = new ExchangeSourceDefinition();

            var hashCode = exchangeSourceDefinition.GetHashCode();

            Assert.AreEqual(0, hashCode);
        }
        public void ExchangeSourceDefinition_Equals_ExchangeSource_Null_Expected_False()
        {
            var exchangeSourceDefinition = new ExchangeSourceDefinition();

            const IExchangeSource exchangeSource = null;

            var isEqual = exchangeSourceDefinition.Equals(exchangeSource);
            Assert.IsFalse(isEqual);
        }
        public IExchangeSource FetchSource(Guid exchangeSourceResourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(exchangeSourceResourceID);
            var db   = new ExchangeSource(xaml.ToXElement());

            var def = new ExchangeSourceDefinition(db);

            return(def);
        }
        public void SavedSource_Itself_Is_Equal()
        {
            //---------------Set up test pack-------------------
            var exchangeEmailActivity = new ExchangeSourceDefinition
            {
                ResourceID = Guid.NewGuid(),
                Path       = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsTrue(exchangeEmailActivity.Equals(exchangeEmailActivity), "Equals operator can't compare to itself.");
        }
        public void SavedSource_Null_Object_Is_NotEqual()
        {
            //---------------Set up test pack-------------------
            var exchangeEmailActivity = new ExchangeSourceDefinition
            {
                ResourceID = Guid.NewGuid(),
                Path       = "A"
            };

            //---------------Assert Precondition----------------
            Assert.IsFalse(exchangeEmailActivity.Equals(null), "Equals operator can't compare to null.");
        }
        public void ExchangeSourceDefinition_Equals_Object_Expected_False()
        {
            var expectedResourceID = Guid.NewGuid();
            const string expectedAutoDiscoverUrl = "testAutoDiscoverUrl";
            const string expectedUserName = "******";
            const string expectedPassword = "******";
            const enSourceType expectedType = enSourceType.ExchangeSource;
            const string expectedResourceType = "ExchangeSource";
            const int expectedTimeout = 30;
            const string expectedEmailTo = "testEmailTo";
            const string expectedPath = "testPath";
            var expectedID = Guid.NewGuid();
            const string expectedResourceName = "testResourceName";

            var exchangeSourceDefinition = new ExchangeSourceDefinition
            {
                ResourceID = expectedResourceID,
                AutoDiscoverUrl = expectedAutoDiscoverUrl,
                UserName = expectedUserName,
                Password = expectedPassword,
                Type = expectedType,
                ResourceType = expectedResourceType,
                Timeout = expectedTimeout,
                EmailTo = expectedEmailTo,
                Path = expectedPath,
                Id = expectedID,
                ResourceName = expectedResourceName
            };

            var exchangeSourceDefinitionDup = new ExchangeSourceDefinition
            {
                ResourceID = expectedResourceID,
                AutoDiscoverUrl = "NewAutoDiscoverUrl",
                UserName = expectedUserName,
                Password = expectedPassword,
                Type = expectedType,
                ResourceType = expectedResourceType,
                Timeout = expectedTimeout,
                EmailTo = expectedEmailTo,
                Path = expectedPath,
                Id = expectedID,
                ResourceName = expectedResourceName
            };

            object exchangeSource = exchangeSourceDefinitionDup;

            var isEqual = exchangeSourceDefinition.Equals(exchangeSource);
            Assert.IsFalse(isEqual);
        }
        public void ExchangeSourceDefinition_GetHashCode_Not_Equal_To_Zero()
        {
            const string expectedAutoDiscoverUrl = "testAutoDiscoverUrl";
            const string expectedUserName = "******";
            const string expectedPassword = "******";

            var exchangeSourceDefinition = new ExchangeSourceDefinition
            {
                AutoDiscoverUrl = expectedAutoDiscoverUrl,
                UserName = expectedUserName,
                Password = expectedPassword
            };

            var hashCode = exchangeSourceDefinition.GetHashCode();

            Assert.AreNotEqual(0, hashCode);
        }
        public IExchangeSource FetchSource(Guid exchangeSourceResourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(exchangeSourceResourceID);
            var db   = new ExchangeSource(xaml.ToXElement());

            var def = new ExchangeSourceDefinition
            {
                AutoDiscoverUrl = db.AutoDiscoverUrl,
                Id           = db.ResourceID,
                Password     = db.Password,
                UserName     = db.UserName,
                Path         = "",
                Timeout      = db.Timeout,
                ResourceName = db.ResourceName,
            };

            return(def);
        }
        public void ExchangeSourceDefinition_ReferenceEquals_ExchangeSourceDefinition_Expected_True()
        {
            const string expectedAutoDiscoverUrl = "testAutoDiscoverUrl";
            const string expectedUserName = "******";
            const string expectedPassword = "******";
            const int expectedTimeout = 30;

            var exchangeSourceDefinition = new ExchangeSourceDefinition
            {
                AutoDiscoverUrl = expectedAutoDiscoverUrl,
                UserName = expectedUserName,
                Password = expectedPassword,
                Timeout = expectedTimeout
            };

            var isEqual = exchangeSourceDefinition.Equals(exchangeSourceDefinition);
            Assert.IsTrue(isEqual);
        }
        public void ExchangeSourceDefinition_Validate()
        {
            var expectedResourceID = Guid.NewGuid();
            const string expectedAutoDiscoverUrl = "testAutoDiscoverUrl";
            const string expectedUserName = "******";
            const string expectedPassword = "******";
            const enSourceType expectedType = enSourceType.ExchangeSource;
            const string expectedResourceType = "ExchangeSource";
            const int expectedTimeout = 30;
            const string expectedEmailTo = "testEmailTo";
            const string expectedPath = "testPath";
            var expectedID = Guid.NewGuid();
            const string expectedResourceName = "testResourceName";

            var exchangeSourceDefinition = new ExchangeSourceDefinition
            {
                ResourceID = expectedResourceID,
                AutoDiscoverUrl = expectedAutoDiscoverUrl,
                UserName = expectedUserName,
                Password = expectedPassword,
                Type = expectedType,
                ResourceType = expectedResourceType,
                Timeout = expectedTimeout,
                EmailTo = expectedEmailTo,
                Path = expectedPath,
                Id = expectedID,
                ResourceName = expectedResourceName
            };

            Assert.AreEqual(expectedResourceID, exchangeSourceDefinition.ResourceID);
            Assert.AreEqual(expectedAutoDiscoverUrl, exchangeSourceDefinition.AutoDiscoverUrl);
            Assert.AreEqual(expectedUserName, exchangeSourceDefinition.UserName);
            Assert.AreEqual(expectedPassword, exchangeSourceDefinition.Password);
            Assert.AreEqual(expectedType, exchangeSourceDefinition.Type);
            Assert.AreEqual(expectedResourceType, exchangeSourceDefinition.ResourceType);
            Assert.AreEqual(expectedTimeout, exchangeSourceDefinition.Timeout);
            Assert.AreEqual(expectedEmailTo, exchangeSourceDefinition.EmailTo);
            Assert.AreEqual(expectedPath, exchangeSourceDefinition.Path);
            Assert.AreEqual(expectedID, exchangeSourceDefinition.Id);
            Assert.AreEqual(expectedResourceName, exchangeSourceDefinition.ResourceName);
        }
        public void ExchangeSourceDefinition_Equals_ExchangeSource_Expected_True()
        {
            const string expectedAutoDiscoverUrl = "testAutoDiscoverUrl";
            const string expectedUserName = "******";
            const string expectedPassword = "******";
            const int expectedTimeout = 30;

            var exchangeSourceDefinition = new ExchangeSourceDefinition
            {
                AutoDiscoverUrl = expectedAutoDiscoverUrl,
                UserName = expectedUserName,
                Password = expectedPassword,
                Timeout = expectedTimeout
            };

            var mockExchangeSource = new Mock<IExchangeSource>();
            mockExchangeSource.Setup(exchangeSource => exchangeSource.AutoDiscoverUrl).Returns(expectedAutoDiscoverUrl);
            mockExchangeSource.Setup(exchangeSource => exchangeSource.UserName).Returns(expectedUserName);
            mockExchangeSource.Setup(exchangeSource => exchangeSource.Password).Returns(expectedPassword);
            mockExchangeSource.Setup(exchangeSource => exchangeSource.Timeout).Returns(expectedTimeout);

            var isEqual = exchangeSourceDefinition.Equals(mockExchangeSource.Object);
            Assert.IsTrue(isEqual);
        }
예제 #14
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);
        }
        protected void BuildDataList(string result)
        {
            List <Tuple <string, string> > variableList;

            scenarioContext.TryGetValue("variableList", out variableList);

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

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

            string body;

            scenarioContext.TryGetValue("body", out body);
            string subject;

            scenarioContext.TryGetValue("subject", out subject);
            string password;

            scenarioContext.TryGetValue("password", out password);
            string simulationOutput;

            scenarioContext.TryGetValue("simulationOutput", out simulationOutput);
            string to;

            scenarioContext.TryGetValue("to", out to);

            var server = SimpleSmtpServer.Start(25);

            scenarioContext.Add("server", server);

            var resourceID          = Guid.NewGuid();
            var resourceName        = 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>();
            // ReSharper disable once RedundantAssignment
            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))
            .Returns(result)
            .Callback((IExchangeSource source, IWarewolfListIterator listIterator, IWarewolfIterator i1, IWarewolfIterator i2, IWarewolfIterator i3, IWarewolfIterator i4, IWarewolfIterator i5, IWarewolfIterator i6, ErrorResultTO errors) =>
            {
                listIterator.FetchNextValue(i1);
                listIterator.FetchNextValue(i2);
                listIterator.FetchNextValue(i3);
                listIterator.FetchNextValue(i4);
                listIterator.FetchNextValue(i5);
                listIterator.FetchNextValue(i6);
            });
            var sendEmail = new DsfExchangeEmailActivity(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
            };

            TestStartNode = new FlowStep
            {
                Action = sendEmail
            };
            scenarioContext.Add("activity", sendEmail);
        }