示例#1
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);
                }
            }
        }
示例#2
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);
        }
示例#3
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);
        }