public void CreateWithName_NotGeneric_Throws()
        {
            var    descriptor = TaskOrchestrationDescriptor.Create <TestOrchestration>();
            var    creator    = new OrchestrationObjectCreator(descriptor);
            Action act        = () => creator.Create(new TypeShortName(typeof(string)));

            act.Should().ThrowExactly <InvalidOperationException>();
        }
        public void Create_GenericDef_Throws()
        {
            var    descriptor = new TaskOrchestrationDescriptor(typeof(TestOrchestration <>));
            var    creator    = new OrchestrationObjectCreator(descriptor);
            Action act        = () => creator.Create();

            act.Should().ThrowExactly <InvalidOperationException>();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="OrchestrationObjectCreator"/> class.
        /// </summary>
        /// <param name="descriptor">The orchestration descriptor. Not null.</param>
        public OrchestrationObjectCreator(TaskOrchestrationDescriptor descriptor)
        {
            Check.NotNull(descriptor, nameof(descriptor));
            Name    = descriptor.Name;
            Version = descriptor.Version;

            _descriptor = descriptor;
        }
Example #4
0
        public void Create_ConcreteType_Succeeds()
        {
            var descriptor = TaskOrchestrationDescriptor.Create <TestOrchestration>();

            descriptor.Should().NotBeNull();
            descriptor.Type.Should().Be(typeof(TestOrchestration));
            descriptor.Name.Should().Be(typeof(TestOrchestration).FullName);
            descriptor.Version.Should().BeEmpty();
        }
Example #5
0
        public void Ctor_DefaultNameVersion(Type type)
        {
            var descriptor = new TaskOrchestrationDescriptor(type);

            descriptor.Should().NotBeNull();
            descriptor.Type.Should().Be(type);
            descriptor.Name.Should().Be(TypeShortName.ToString(type, false));
            descriptor.Version.Should().BeEmpty();
        }
        public void Create_WrapperCreated()
        {
            var descriptor = TaskOrchestrationDescriptor.Create <TestOrchestration>();
            var creator    = new OrchestrationObjectCreator(descriptor);
            TaskOrchestration Orchestration = creator.Create();

            Orchestration.Should().NotBeNull();
            Orchestration.Should().BeOfType <WrapperOrchestration>()
            .Which.Descriptor.Should().Be(descriptor);
        }
Example #7
0
        public void Create_SuppliedNameVersion()
        {
            const string name       = "CustomName";
            const string version    = "CustomVersion";
            var          descriptor = TaskOrchestrationDescriptor.Create <TestOrchestration>(name, version);

            descriptor.Should().NotBeNull();
            descriptor.Type.Should().Be(typeof(TestOrchestration));
            descriptor.Name.Should().Be(name);
            descriptor.Version.Should().Be(version);
        }
Example #8
0
        public void Ctor_SuppliedNameVersion(Type type)
        {
            const string name       = "CustomName";
            const string version    = "CustomVersion";
            var          descriptor = new TaskOrchestrationDescriptor(type, name, version);

            descriptor.Should().NotBeNull();
            descriptor.Type.Should().Be(type);
            descriptor.Name.Should().Be(name);
            descriptor.Version.Should().Be(version);
        }
        public void AddOrchestrationGenericNamed_Added(string name, string version)
        => RunTest(
            builder => builder.AddOrchestration <TestOrchestration>(name, version),
            (original, result) =>
        {
            result.Should().NotBeNull();
            result.Should().BeSameAs(original);
            original.Orchestrations.Should().HaveCount(1);

            TaskOrchestrationDescriptor descriptor = original.Orchestrations.Single();
            descriptor.Type.Should().Be(typeof(TestOrchestration));
            descriptor.Name.Should().Be(name);
            descriptor.Version.Should().Be(version);

            original.Activities.Should().BeEmpty();
            original.ActivityMiddleware.Should().HaveCount(1);
            original.OrchestrationMiddleware.Should().HaveCount(1);
        });
 public void AddOrchestrationType_Added2(bool includeAliases, int count)
 => RunTest(
     builder => builder.AddOrchestration(typeof(TestOrchestration), includeAliases),
     (original, result) =>
 {
     result.Should().NotBeNull();
     result.Should().BeSameAs(original);
     original.Orchestrations.Should().HaveCount(count);
     original.Orchestrations.Should().OnlyContain(x => x.Type == typeof(TestOrchestration));
     if (includeAliases)
     {
         TaskOrchestrationDescriptor descriptor = original.Orchestrations.First();
         Type t = descriptor.Type;
         foreach (TaskAliasAttribute alias in t.GetCustomAttributes <TaskAliasAttribute>())
         {
             string expectedName    = alias.Name ?? descriptor.Name;
             string expectedVersion = alias.Version ?? descriptor.Version;
             original.Orchestrations.Should().Contain(x => x.Type == t && x.Name == expectedName && x.Version == expectedVersion);
         }
     }
     original.Activities.Should().BeEmpty();
     original.ActivityMiddleware.Should().HaveCount(1);
     original.OrchestrationMiddleware.Should().HaveCount(1);
 });
Example #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WrapperOrchestration"/> class.
 /// </summary>
 /// <param name="descriptor">The inner orchestration descriptor.</param>
 public WrapperOrchestration(TaskOrchestrationDescriptor descriptor)
 {
     Descriptor = Check.NotNull(descriptor, nameof(descriptor));
 }
Example #12
0
        public void Create_AbstractType_Fails()
        {
            Action act = () => TaskOrchestrationDescriptor.Create <TaskOrchestration>();

            act.Should().ThrowExactly <ArgumentException>();
        }
 public void CreateWithName_GenericDef_ArgNull_Throws()
 {
     var    descriptor = new TaskOrchestrationDescriptor(typeof(TestOrchestration <>));
     var    creator    = new OrchestrationObjectCreator(descriptor);
     Action act        = () => creator.Create(default);