Exemplo n.º 1
0
        public void EmailSourcesTestWithInValidArgsExpectedInvalidValidationResult()
        {
            var handler = new EmailSources();
            var result  = handler.Test("root:'hello'", Guid.Empty, Guid.Empty);

            Assert.IsFalse(result.IsValid);
        }
Exemplo n.º 2
0
        public void EmailSourcesGetWithValidArgsExpectedReturnsSource()
        {
            var expected = CreateYahooSource();
            var saveArgs = expected.ToString();

            var workspaceID   = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);

            try
            {
                var handler = new EmailSources();
                handler.Save(saveArgs, workspaceID, Guid.Empty);

                var actual = handler.Get(expected.ResourceID.ToString(), workspaceID, Guid.Empty);

                VerifySource(actual, expected);
            }
            finally
            {
                if (Directory.Exists(workspacePath))
                {
                    DirectoryHelper.CleanUp(workspacePath);
                }
            }
        }
Exemplo n.º 3
0
        public void EmailSourcesGetWithInvalidArgsExpectedReturnsNewSource()
        {
            var handler = new EmailSources();
            var result  = handler.Get("xxxxx", Guid.Empty, Guid.Empty);

            Assert.IsNotNull(result);
            Assert.AreEqual(Guid.Empty, result.ResourceID);
        }
Exemplo n.º 4
0
        public void EmailSourcesSaveWithInValidArgsExpectedInvalidValidationResult()
        {
            var handler    = new EmailSources();
            var jsonResult = handler.Save("root:'hello'", Guid.Empty, Guid.Empty);
            var result     = JsonConvert.DeserializeObject <ValidationResult>(jsonResult);

            Assert.IsFalse(result.IsValid);
        }
Exemplo n.º 5
0
        public void EmailSourcesTest_LOCAL()
        {
            var source = CreateLocalSource().ToString();

            var handler = new EmailSources();
            var result  = handler.Test(source, Guid.Empty, Guid.Empty);

            Assert.IsTrue(result.IsValid, result.ErrorMessage);
        }
Exemplo n.º 6
0
        public void EmailSourcesTest_HOTMAIL_SSL()
        {
            var source = CreateWindowsLiveSource().ToString();

            var handler = new EmailSources();
            var result  = handler.Test(source, Guid.Empty, Guid.Empty);

            Assert.IsTrue(result.IsValid, result.ErrorMessage);
        }
Exemplo n.º 7
0
        public void EmailSourcesTestWithInvalidHostExpectedInvalidValidationResult()
        {
            var source = new EmailSource {
                Host = "smtp.foobar.com", Port = 25
            }.ToString();

            var handler = new EmailSources();
            var result  = handler.Test(source, Guid.Empty, Guid.Empty);

            Assert.IsFalse(result.IsValid, result.ErrorMessage);
        }
Exemplo n.º 8
0
        void SetSelectedEmailSource(Resource source)
        {
            var selectedSource = source == null ? null : EmailSources.FirstOrDefault(d => d.ResourceID == source.ResourceID);

            if (selectedSource == null)
            {
                if (EmailSources.FirstOrDefault(d => d.Equals(SelectEmailSource)) == null)
                {
                    EmailSources.Insert(0, SelectEmailSource);
                }
                selectedSource = SelectEmailSource;
            }
            SelectedEmailSource = selectedSource;
        }
        void LoadSources(System.Action continueWith = null)
        {
            EmailSources.Clear();
            EmailSources.Add(NewEmailSource);

            _asyncWorker.Start(() => GetEmailSources().OrderBy(r => r.ResourceName), sources =>
            {
                foreach (var source in sources)
                {
                    EmailSources.Add(source);
                }
                continueWith?.Invoke();
            });
        }
Exemplo n.º 10
0
        protected virtual void OnSelectedEmailSourceChanged()
        {
            if (SelectedEmailSource == NewEmailSource)
            {
                CreateEmailSource();
                return;
            }

            IsRefreshing = true;

            if (SelectedEmailSource != SelectEmailSource)
            {
                EmailSources.Remove(SelectEmailSource);
            }
            EmailSource = SelectedEmailSource;
        }
Exemplo n.º 11
0
        public void EmailSourcesSaveWithValidArgsExpectedInvokesResourceCatalogSave()
        {
            var expected = CreateYahooSource();

            var catalog = new Mock <IResourceCatalog>();

            catalog.Setup(c => c.SaveResource(It.IsAny <Guid>(), It.IsAny <IResource>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Verifiable();

            var handler    = new EmailSources(catalog.Object);
            var jsonResult = handler.Save(expected.ToString(), Guid.Empty, Guid.Empty);
            var actual     = JsonConvert.DeserializeObject <EmailSource>(jsonResult);

            catalog.Verify(c => c.SaveResource(It.IsAny <Guid>(), It.IsAny <IResource>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()));

            VerifySource(expected, actual);
        }
Exemplo n.º 12
0
 public void EmailSourcesConstructorWithNullResourceCatalogExpectedThrowsArgumentNullException()
 {
     var handler = new EmailSources(null);
 }
Exemplo n.º 13
0
 public void EmailSourcesConstructorWithNullResourceCatalogExpectedThrowsArgumentNullException()
 {
     // ReSharper disable once UnusedVariable
     var handler = new EmailSources(null);
 }