2010-04-08 19:54:41 -07:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Orchard.Commands;
|
|
|
|
|
|
|
|
|
|
namespace Orchard.Tests.Commands {
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class CommandHandlerDescriptorBuilderTests {
|
|
|
|
|
[Test]
|
|
|
|
|
public void BuilderShouldCreateDescriptor() {
|
|
|
|
|
var builder = new CommandHandlerDescriptorBuilder();
|
|
|
|
|
var descriptor = builder.Build(typeof(MyCommand));
|
|
|
|
|
Assert.That(descriptor, Is.Not.Null);
|
|
|
|
|
Assert.That(descriptor.Commands.Count(), Is.EqualTo(4));
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "FooBar"), Is.Not.Null);
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "FooBar").MethodInfo, Is.EqualTo(typeof(MyCommand).GetMethod("FooBar")));
|
2010-04-12 17:49:16 -07:00
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "MyCommand"), Is.Not.Null);
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "MyCommand").MethodInfo, Is.EqualTo(typeof(MyCommand).GetMethod("FooBar2")));
|
2010-04-08 19:54:41 -07:00
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "Foo Bar"), Is.Not.Null);
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "Foo Bar").MethodInfo, Is.EqualTo(typeof(MyCommand).GetMethod("Foo_Bar")));
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "Foo_Bar"), Is.Not.Null);
|
|
|
|
|
Assert.That(descriptor.Commands.Single(d => d.Name == "Foo_Bar").MethodInfo, Is.EqualTo(typeof(MyCommand).GetMethod("Foo_Bar3")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class MyCommand : DefaultOrchardCommandHandler {
|
|
|
|
|
public void FooBar() {
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 17:49:16 -07:00
|
|
|
|
[CommandName("MyCommand")]
|
2010-04-08 19:54:41 -07:00
|
|
|
|
public void FooBar2() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Foo_Bar() {
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 17:49:16 -07:00
|
|
|
|
[CommandName("Foo_Bar")]
|
2010-04-08 19:54:41 -07:00
|
|
|
|
public void Foo_Bar3() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|