Ejemplo n.º 1
0
        public void ExchangeSource_Equals()
        {
            var testDbSource = new ExchangeSource();
            var result       = testDbSource.Equals(testDbSource);

            Assert.IsTrue(result);
        }
Ejemplo n.º 2
0
        public void ExchangeSource_SetUpProerties_ReturnsNoErrors()
        {
            var testDbSource = new ExchangeSource
            {
                DataList        = "This is test string",
                EmailFrom       = "*****@*****.**",
                EmailTo         = "*****@*****.**",
                ResourceName    = "testName",
                Path            = "Test Path",
                TestFromAddress = "*****@*****.**",
                Type            = enSourceType.ExchangeSource,
                Timeout         = 1000,
                TestToAddress   = "*****@*****.**",
                UserName        = "******",
                Password        = "******"
            };

            Assert.IsNotNull(testDbSource.DataList);
            Assert.IsNotNull(testDbSource.EmailFrom);
            Assert.IsNotNull(testDbSource.EmailTo);
            Assert.IsNotNull(testDbSource.Path);
            Assert.IsNotNull(testDbSource.TestFromAddress);
            Assert.IsNotNull(testDbSource.Type);
            Assert.IsNotNull(testDbSource.Timeout);
            Assert.IsNotNull(testDbSource.TestToAddress);
            Assert.IsNotNull(testDbSource.UserName);
            Assert.IsNotNull(testDbSource.Password);
        }
Ejemplo n.º 3
0
        public void ToStringEmptyObjectExpected()
        {
            var testDbSource             = new ExchangeSource();
            var actualSerializedDbSource = testDbSource.ToString();
            var expected = JsonConvert.SerializeObject(testDbSource);

            Assert.AreEqual(expected, actualSerializedDbSource);
        }
Ejemplo n.º 4
0
        public void ToXmlRegardingSource()
        {
            var testDbSource = SetupDefaultSource();
            var expectedXml  = testDbSource.ToXml();

            testDbSource = new ExchangeSource(expectedXml);
            Assert.IsNotNull(testDbSource);
        }
        public IExchangeSource FetchSource(Guid exchangeSourceResourceID)
        {
            var xaml = _queryProxy.FetchResourceXaml(exchangeSourceResourceID);
            var db   = new ExchangeSource(xaml.ToXElement());

            var def = new ExchangeSourceDefinition(db);

            return(def);
        }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Resource Service");
                StringBuilder resourceDefinition;

                values.TryGetValue("ExchangeSource", out resourceDefinition);

                var src = serializer.Deserialize <ExchangeSourceDefinition>(resourceDefinition);

                var con = new ExchangeSource()
                {
                    AutoDiscoverUrl = src.AutoDiscoverUrl,
                    UserName        = src.UserName,
                    Password        = src.Password,
                    Timeout         = src.Timeout,
                };

                var testMessage = new ExchangeTestMessage()
                {
                    Tos = new List <string> {
                        src.EmailTo,
                    },
                    CCs = new List <string> {
                        string.Empty
                    },
                    BcCs = new List <string> {
                        string.Empty
                    },
                    Subject = "Exchange Email Test",
                    Body    = "Test Exchange email service source",
                };

                con.Send(new ExchangeEmailSender(con), testMessage);
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 7
0
        public void ToXmlEmptyObjectExpectedXElementContainingNoInformationRegardingSource()
        {
            var testDbSource = new ExchangeSource();
            var expectedXml  = testDbSource.ToXml();

            var attrib     = expectedXml.Attributes();
            var attribEnum = attrib.GetEnumerator();

            while (attribEnum.MoveNext())
            {
                if (attribEnum.Current.Name == "Name")
                {
                    Assert.AreEqual(string.Empty, attribEnum.Current.Value);
                    break;
                }
            }
        }
        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);
        }
 private void SendEmail(ExchangeSource testSource, ExchangeTestMessage testMessage)
 {
     _asyncWorker.Start(() =>
     {
         try
         {
             testSource.Send(new ExchangeEmailSender(testSource), testMessage);
         }
         catch (Exception)
         {
             SetStatusMessage("One or more errors occured");
         }
         finally
         {
             Testing = false;
         }
     });
 }
        public StringBuilder Execute(Dictionary <string, StringBuilder> values, IWorkspace theWorkspace)
        {
            ExecuteMessage     msg        = new ExecuteMessage();
            Dev2JsonSerializer serializer = new Dev2JsonSerializer();

            try
            {
                Dev2Logger.Info("Save Exchange Service Source");
                StringBuilder resourceDefinition;

                values.TryGetValue("ExchangeSource", out resourceDefinition);

                var src = serializer.Deserialize <ExchangeSourceDefinition>(resourceDefinition);
                var con = new ExchangeSource
                {
                    AutoDiscoverUrl = src.AutoDiscoverUrl,
                    UserName        = src.UserName,
                    Password        = src.Password,
                    Timeout         = src.Timeout,
                    ResourceName    = src.ResourceName,
                    ResourceID      = src.Id,
                    Type            = enSourceType.ExchangeSource,
                    ResourceType    = "ExchangeSource"
                };
                ResourceCatalog.Instance.SaveResource(GlobalConstants.ServerWorkspaceID, con, src.Path);
                ServerExplorerRepo.UpdateItem(con);

                msg.HasError = false;
            }
            catch (Exception err)
            {
                msg.HasError = true;
                msg.Message  = new StringBuilder(err.Message);
                Dev2Logger.Error(err);
            }

            return(serializer.SerializeToBuilder(msg));
        }
Ejemplo n.º 11
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);
        }
        public void TestEmailAccount()
        {
            if (Errors != null && Errors.Count > 0)
            {
                return;
            }

            Testing       = true;
            StatusMessage = string.Empty;

            if (string.IsNullOrEmpty(To))
            {
                Testing = false;
                Errors  = new List <IActionableErrorInfo> {
                    new ActionableErrorInfo(() => IsToFocused = true)
                    {
                        Message = ErrorResource.ToAddressRequired
                    }
                };
                return;
            }
            if (SourceRegion.SelectedSource == null)
            {
                Testing = false;
                Errors  = new List <IActionableErrorInfo> {
                    new ActionableErrorInfo(() => IsToFocused = true)
                    {
                        Message = ErrorResource.InvalidSource
                    }
                };
                return;
            }

            var testSource = new ExchangeSource()
            {
                AutoDiscoverUrl = SourceRegion.SelectedSource.AutoDiscoverUrl,
                Password        = SourceRegion.SelectedSource.Password,
                UserName        = SourceRegion.SelectedSource.UserName,
            };

            var testMessage = new ExchangeTestMessage()
            {
                Body    = Body,
                Subject = Subject,
            };

            if (!string.IsNullOrEmpty(Attachments))
            {
                var attachments = Attachments.Split(';');
                testMessage.Attachments.AddRange(attachments);
            }

            if (!string.IsNullOrEmpty(To))
            {
                var tos = To.Split(';');
                testMessage.Tos.AddRange(tos);
            }

            if (!string.IsNullOrEmpty(Cc))
            {
                var ccs = Cc.Split(';');
                testMessage.CCs.AddRange(ccs);
            }

            if (!string.IsNullOrEmpty(Bcc))
            {
                var bccs = Bcc.Split(';');
                testMessage.BcCs.AddRange(bccs);
            }

            SendEmail(testSource, testMessage);
        }
        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);
        }