1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace Microsoft.DbContextPackage.Extensions
{
using System.Xml.Linq;
using Xunit;
public class XContainerExtensionsTests
{
private const string _elementName = "Element";
private readonly XNamespace _ns1 = "http://tempuri.org/1";
private readonly XNamespace _ns2 = "http://tempuri.org/2";
private readonly XElement _element1;
private readonly XContainer _container;
public XContainerExtensionsTests()
{
_element1 = new XElement(_ns1 + _elementName);
_container = new XElement(
"Container",
new XElement(_elementName),
_element1,
new XElement(_ns2 + _elementName));
}
[Fact]
public void Element_returns_first_match()
{
var element = _container.Element(
new[] { _ns1, _ns2 },
_elementName);
Assert.Same(_element1, element);
}
[Fact]
public void Element_returns_null_when_no_match()
{
XNamespace ns3 = "http://tempuri.org/3";
var element = _container.Element(
new[] { ns3 },
_elementName);
Assert.Null(element);
}
}
}
|