Пример #1
0
        protected internal RoomieCommand(ICommandSpecification specificationOverrides = null)
        {
            var type = GetType();

            var specification = new CompositeCommandSpecification(
                specificationOverrides ?? new ReadOnlyCommandSpecification(),
                new AttributeBasedCommandSpecification(type),
                new NamespaceBasedCommandSpecification(type)
                );

            Name = specification.Name;
            Group = specification.Group;
            Description = specification.Description;
            Source = specification.Source;
            ExtensionName = specification.ExtensionName;
            ExtensionVersion = specification.ExtensionVersion;
            Arguments = specification.Arguments;

            if (Group == null)
            {
                throw new Exception("Command " + Name + "'s is not set");
            }

            Finalized = true;

            if (GetType().GetCustomAttributes(typeof (NotFinishedAttribute), true).Any())
            {
                Finalized = false;
            }
        }
        public void GroupWorks(string first, string second, string expected)
        {
            var specification = new CompositeCommandSpecification(
                new ReadOnlyCommandSpecification(group: first),
                new ReadOnlyCommandSpecification(group: second));

            Assert.That(specification.Group, Is.EqualTo(expected));
        }
        public void ExtensionVersionWorks(string first, string second, string expected)
        {
            var specification = new CompositeCommandSpecification(
                new ReadOnlyCommandSpecification(extensionVersion: GetVersion(first)),
                new ReadOnlyCommandSpecification(extensionVersion: GetVersion(second)));

            Assert.That(specification.ExtensionVersion, Is.EqualTo(GetVersion(expected)));
        }
        public void ExtensionNameWorks(string first, string second, string expected)
        {
            var specification = new CompositeCommandSpecification(
                new ReadOnlyCommandSpecification(extensionName: first),
                new ReadOnlyCommandSpecification(extensionName: second));

            Assert.That(specification.ExtensionName, Is.EqualTo(expected));
        }
        public void DescriptionWorks(string first, string second, string expected)
        {
            var specification = new CompositeCommandSpecification(
                new ReadOnlyCommandSpecification(description: first),
                new ReadOnlyCommandSpecification(description: second));

            Assert.That(specification.Description, Is.EqualTo(expected));
        }
        public void ArgumentsWorks(string first, string second, string expected)
        {
            var specification = new CompositeCommandSpecification(
                new ReadOnlyCommandSpecification(arguments: GetArguments(first)),
                new ReadOnlyCommandSpecification(arguments: GetArguments(second)));

            var actual = specification.Arguments;

            if (expected == null)
            {
                Assert.That(actual, Is.Null);
            }
            else
            {
                Assert.That(string.Join(",", actual.Select(x => x.Name)), Is.EqualTo(expected));
            }
        }