Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace Microsoft.DbContextPackage.Extensions
{
using Xunit;
using System.CodeDom.Compiler;
using System.Linq;
public class CompilerErrorCollectionExtensionsTests
{
[Fact]
public void HandleErrors_is_noop_when_no_errors()
{
var errors = new CompilerErrorCollection
{
new CompilerError { IsWarning = true }
};
errors.HandleErrors("Not used");
}
[Fact]
public void HandleErrors_throws_when_errors()
{
var error = new CompilerError { IsWarning = false };
var errors = new CompilerErrorCollection { error };
var message = "Some message";
var ex = Assert.Throws<CompilerErrorException>(
() => errors.HandleErrors(message));
Assert.Equal(message, ex.Message);
Assert.NotNull(ex.Errors);
Assert.Equal(1, ex.Errors.Count());
Assert.Same(error, ex.Errors.Single());
}
}
}

View File

@@ -0,0 +1,55 @@
// 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;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Xunit;
public class CompilerErrorExceptionTests
{
[Fact]
public void Ctor_validates_preconditions()
{
IEnumerable<CompilerError> errors = null;
var ex = Assert.Throws<ArgumentNullException>(
() => new CompilerErrorException("Not used", errors));
Assert.Equal("errors", ex.ParamName);
}
[Fact]
public void Ctor_sets_properties()
{
var message = "Some message";
var errors = new CompilerError[0];
var ex = new CompilerErrorException(message, errors);
Assert.Equal(message, ex.Message);
Assert.Same(errors, ex.Errors);
}
[Fact]
public void Is_serializable()
{
var message = "Some message";
var errors = new CompilerError[0];
var formatter = new BinaryFormatter();
CompilerErrorException ex;
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, new CompilerErrorException(message, errors));
stream.Position = 0;
ex = (CompilerErrorException)formatter.Deserialize(stream);
}
Assert.Equal(message, ex.Message);
Assert.Equal(errors, ex.Errors);
}
}
}

View File

@@ -0,0 +1,55 @@
// 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;
using System.Collections.Generic;
using System.Data.Metadata.Edm;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Xunit;
public class EdmSchemaErrorExceptionTests
{
[Fact]
public void Ctor_validates_preconditions()
{
IEnumerable<EdmSchemaError> errors = null;
var ex = Assert.Throws<ArgumentNullException>(
() => new EdmSchemaErrorException("Not used", errors));
Assert.Equal("errors", ex.ParamName);
}
[Fact]
public void Ctor_sets_properties()
{
var message = "Some message";
var errors = new EdmSchemaError[0];
var ex = new EdmSchemaErrorException(message, errors);
Assert.Equal(message, ex.Message);
Assert.Same(errors, ex.Errors);
}
[Fact]
public void Is_serializable()
{
var message = "Some message";
var errors = new EdmSchemaError[0];
var formatter = new BinaryFormatter();
EdmSchemaErrorException ex;
using (var stream = new MemoryStream())
{
formatter.Serialize(stream, new EdmSchemaErrorException(message, errors));
stream.Position = 0;
ex = (EdmSchemaErrorException)formatter.Deserialize(stream);
}
Assert.Equal(message, ex.Message);
Assert.Equal(errors, ex.Errors);
}
}
}

View File

@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace Microsoft.DbContextPackage.Extensions
{
using Microsoft.VisualStudio.ComponentModelHost;
using Moq;
using Xunit;
public class IComponentModelExtensionsTests
{
[Fact]
public void GetService_calls_generic_version()
{
var componentModelMock = new Mock<IComponentModel>();
var componentModel = componentModelMock.Object;
componentModel.GetService(typeof(string));
componentModelMock.Verify(cm => cm.GetService<string>(), Times.Once());
}
}
}

View File

@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace Microsoft.DbContextPackage.Extensions
{
using Xunit;
public class StringExtensionsTests
{
[Fact]
public void EqualsIgnoreCase_tests_equality()
{
Assert.True(StringExtensions.EqualsIgnoreCase(null, null));
Assert.True("one".EqualsIgnoreCase("one"));
Assert.True("two".EqualsIgnoreCase("TWO"));
Assert.False("three".EqualsIgnoreCase("four"));
Assert.False("five".EqualsIgnoreCase(null));
}
}
}

View File

@@ -0,0 +1,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);
}
}
}