Remove RazorDirectiveAttribute and related tests.
- These were not used. #344
This commit is contained in:
parent
261dd108fd
commit
1ac518d9cb
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.AspNet.Razor
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a Razor directive that is rendered as an attribute on the generated class.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class RazorDirectiveAttribute : Attribute
|
||||
{
|
||||
public RazorDirectiveAttribute(string name, string value)
|
||||
{
|
||||
if (String.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "name");
|
||||
}
|
||||
|
||||
Name = name;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string Value { get; private set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var attribute = obj as RazorDirectiveAttribute;
|
||||
return attribute != null &&
|
||||
Name.Equals(attribute.Name, StringComparison.OrdinalIgnoreCase) &&
|
||||
StringComparer.OrdinalIgnoreCase.Equals(Value, attribute.Value);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (StringComparer.OrdinalIgnoreCase.GetHashCode(Name) * 31) +
|
||||
(Value == null ? 0 : StringComparer.OrdinalIgnoreCase.GetHashCode(Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Razor.Test
|
||||
{
|
||||
public class RazorDirectiveAttributeTest
|
||||
{
|
||||
[Fact]
|
||||
public void ConstructorThrowsIfNameIsNullOrEmpty()
|
||||
{
|
||||
// Act and Assert
|
||||
Assert.Throws<ArgumentException>("name", () => new RazorDirectiveAttribute(name: null, value: "blah"));
|
||||
Assert.Throws<ArgumentException>("name", () => new RazorDirectiveAttribute(name: "", value: "blah"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsureRazorDirectiveProperties()
|
||||
{
|
||||
// Arrange
|
||||
var attribute = typeof(RazorDirectiveAttribute)
|
||||
.GetTypeInfo()
|
||||
.GetCustomAttribute<AttributeUsageAttribute>(inherit: false);
|
||||
|
||||
// Assert
|
||||
Assert.True(attribute.AllowMultiple);
|
||||
Assert.True(attribute.ValidOn == AttributeTargets.Class);
|
||||
Assert.True(attribute.Inherited);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualsAndGetHashCodeIgnoresCase()
|
||||
{
|
||||
// Arrange
|
||||
var attribute1 = new RazorDirectiveAttribute("foo", "bar");
|
||||
var attribute2 = new RazorDirectiveAttribute("fOo", "BAr");
|
||||
|
||||
// Act
|
||||
var hashCode1 = attribute1.GetHashCode();
|
||||
var hashCode2 = attribute2.GetHashCode();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(attribute1, attribute2);
|
||||
Assert.Equal(hashCode1, hashCode2);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualsAndGetHashCodeDoNotThrowIfValueIsNullOrEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var attribute1 = new RazorDirectiveAttribute("foo", null);
|
||||
var attribute2 = new RazorDirectiveAttribute("foo", "BAr");
|
||||
|
||||
// Act
|
||||
var result = attribute1.Equals(attribute2);
|
||||
var hashCode = attribute1.GetHashCode();
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
// If we've got this far, GetHashCode did not throw
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EqualsAndGetHashCodeReturnDifferentValuesForNullAndEmpty()
|
||||
{
|
||||
// Arrange
|
||||
var attribute1 = new RazorDirectiveAttribute("foo", null);
|
||||
var attribute2 = new RazorDirectiveAttribute("foo", "");
|
||||
|
||||
// Act
|
||||
var result = attribute1.Equals(attribute2);
|
||||
var hashCode1 = attribute1.GetHashCode();
|
||||
var hashCode2 = attribute2.GetHashCode();
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
Assert.NotEqual(hashCode1, hashCode2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue