Inheritance: Dev2.Runtime.Diagnostics.ExceptionManager
Beispiel #1
0
        public void WebSourcesConstructorWithNullResourceCatalogExpectedThrowsArgumentNullException()
        {
#pragma warning disable 168
            // ReSharper disable UnusedVariable
            var handler = new WebSources(null);
            // ReSharper restore UnusedVariable
#pragma warning restore 168
        }
Beispiel #2
0
        public void WebSourcesTestWithInvalidAddressExpectedInvalidValidationResult()
        {
            var source = new WebSource { Address = "www.foo.bar", AuthenticationType = AuthenticationType.Anonymous }.ToString();

            var handler = new WebSources();
            var result = handler.Test(source, Guid.Empty, Guid.Empty);
            Assert.IsFalse(result.IsValid, result.ErrorMessage);
        }
Beispiel #3
0
 public void WebSourcesTestWithInValidArgsExpectedInvalidValidationResult()
 {
     var handler = new WebSources();
     var result = handler.Test("root:'hello'", Guid.Empty, Guid.Empty);
     Assert.IsFalse(result.IsValid);
 }
Beispiel #4
0
        public void WebSourcesSaveWithValidArgsExpectedInvokesResourceCatalogSave()
        {
            var expected = CreateWebSource();

            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 WebSources(catalog.Object);
            var jsonResult = handler.Save(expected.ToString(), Guid.Empty, Guid.Empty);
            var actual = JsonConvert.DeserializeObject<WebSource>(jsonResult);

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

            VerifySource(expected, actual);
        }
Beispiel #5
0
 public void WebSourcesSaveWithInValidArgsExpectedInvalidValidationResult()
 {
     var handler = new WebSources();
     var jsonResult = handler.Save("root:'hello'", Guid.Empty, Guid.Empty);
     var result = JsonConvert.DeserializeObject<ValidationResult>(jsonResult);
     Assert.IsFalse(result.IsValid);
 }
Beispiel #6
0
        public void WebSourcesGetWithValidArgsExpectedReturnsSource()
        {
            var expected = CreateWebSource();
            var saveArgs = expected.ToString();

            var workspaceID = Guid.NewGuid();
            var workspacePath = EnvironmentVariables.GetWorkspacePath(workspaceID);
            try
            {
                var handler = new WebSources();
                handler.Save(saveArgs, workspaceID, Guid.Empty);

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

                VerifySource(actual, expected);
            }
            finally
            {
                try
                {
                    if(Directory.Exists(workspacePath))
                    {
                        DirectoryHelper.CleanUp(workspacePath);
                    }
                }
                // ReSharper disable EmptyGeneralCatchClause
                catch(Exception)
                // ReSharper restore EmptyGeneralCatchClause
                {
                }
            }
        }
Beispiel #7
0
        public void WebSourcesGetWithInvalidArgsExpectedReturnsNewSource()
        {
            var handler = new WebSources();
            var result = handler.Get("xxxxx", Guid.Empty, Guid.Empty);

            Assert.IsNotNull(result);
            Assert.AreEqual(Guid.Empty, result.ResourceID);
        }