Beispiel #1
0
            public void Should_Get_Attribute_Value()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture();

                // When
                var result = fixture.Peek("/configuration/appSettings/add[@key = 'server']/@value");

                // Then
                Assert.Equal("testhost.somecompany.com", result);
            }
Beispiel #2
0
            public void Should_Get_Node_Value()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture();

                // When
                var result = fixture.Peek("/configuration/test/text()");

                // Then
                Assert.Equal("test value", result);
            }
Beispiel #3
0
            public void Should_Throw_If_No_Xpath()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture();

                // When
                var result = Record.Exception(() => fixture.Peek(null));

                // Then
                AssertEx.IsArgumentNullException(result, "xpath");
            }
Beispiel #4
0
            public void Should_Throw_If_File_Has_Dtd()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture(xmlWithDtd: true);

                // When
                var result = Record.Exception(() => fixture.Peek("CFBundleDisplayName"));

                // Then
                Assert.IsType <System.Xml.XmlException>(result);
            }
Beispiel #5
0
            public void Should_Throw_If_FilePath_Is_Null()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture(false);

                // When
                var result = Record.Exception(() => fixture.Peek("gibblygook"));

                // Then
                AssertEx.IsArgumentNullException(result, "filePath");
            }
Beispiel #6
0
            public void Should_Get_Node_Value_From_File_With_Dtd()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture(xmlWithDtd: true);

                fixture.Settings.DtdProcessing = XmlDtdProcessing.Parse;

                // When
                var result = fixture.Peek("/plist/dict/key/text()");

                // Then
                Assert.Equal("CFBundleDisplayName", result);
            }
Beispiel #7
0
            public void Should_Throw_If_File_Does_Not_Exists()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture(false);

                fixture.XmlPath = "/Working/web.config";

                // When
                var result = Record.Exception(() => fixture.Peek("gibblygook"));

                // Then
                Assert.IsType <FileNotFoundException>(result);
            }
Beispiel #8
0
            public void Should_Not_Log_Unknown_Warning_With_Suppress_Warnings_On()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture(true, false, true);

                // When
                var result = fixture.Peek("/configuration/test2/text()");

                // Then
                Assert.Equal(null, result);
                var warning = fixture.FakeLog.Entries.FirstOrDefault(x => x.Level == LogLevel.Warning);

                Assert.Equal(null, warning);
            }
Beispiel #9
0
            public void Should_Log_Unknown_Warning_With_Suppress_Warnings_Off()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture();

                // When
                var result = fixture.Peek("/configuration/test2/text()");

                // Then
                Assert.Equal(null, result);
                var warning = fixture.FakeLog.Entries.FirstOrDefault(x => x.Level == LogLevel.Warning);

                Assert.Equal("Warning: Failed to find node matching the XPath '/configuration/test2/text()'", warning.Message);
            }
Beispiel #10
0
            public void Should_Get_Element_Value_With_Namespace()
            {
                // Given
                var fixture = new XmlPeekAliasesFixture();

                fixture.SetContent(Properties.Resources.XmlPeek_Xml_With_Namespace);
                fixture.Settings.Namespaces.Add("msbuild", "http://schemas.microsoft.com/developer/msbuild/2003");

                // When
                var result = fixture.Peek("/msbuild:Project/msbuild:PropertyGroup/msbuild:publishUrl");

                // Then
                Assert.Equal("C:\\Deployment\\DeploymentTemplate\\WebApi", result);
            }