public void Create_WrapperCreated()
        {
            var          descriptor = TaskActivityDescriptor.Create <TestActivity>();
            var          creator    = new ActivityObjectCreator(descriptor);
            TaskActivity activity   = creator.Create();

            activity.Should().NotBeNull();
            activity.Should().BeOfType <WrapperActivity>()
            .Which.Descriptor.Should().Be(descriptor);
        }
Exemplo n.º 2
0
        public void Create_NotExists_Null()
        {
            var          manager  = new GenericObjectManager <TaskActivity>();
            TaskActivity activity = manager.GetObject("DNE", "");

            activity.Should().BeNull();
        }
Exemplo n.º 3
0
        public async Task InvokeAsync_NotWrapped_Continues()
        {
            // arrange
            var activity        = new TestActivity();
            var serviceProvider = new Mock <IServiceProvider>();
            DispatchMiddlewareContext context = CreateContext(activity);
            var middleware = new ServiceProviderActivityMiddleware(serviceProvider.Object);

            // act
            await middleware.InvokeAsync(context, () => Task.CompletedTask);

            // assert
            TaskActivity actual = context.GetProperty <TaskActivity>();

            actual.Should().NotBeNull();
            actual.Should().Be(activity);
            serviceProvider.Verify(m => m.GetService(It.IsAny <Type>()), Times.Never);
        }
Exemplo n.º 4
0
        public void Create_OpenGeneric_NotNull(Type type)
        {
            var manager = new GenericObjectManager <TaskActivity>();

            manager.Add(new ActivityObjectCreator(new TaskActivityDescriptor(typeof(TestActivity <>))));
            TaskActivity activity = manager.GetObject(TypeShortName.ToString(type, false), string.Empty);

            activity.Should().NotBeNull();
            activity.As <WrapperActivity>().Descriptor.Type.Should().Be(type);
        }
Exemplo n.º 5
0
        public void Create_Exists_NotNull()
        {
            var manager = new GenericObjectManager <TaskActivity>();

            manager.Add(new ActivityObjectCreator(s_descriptor));
            TaskActivity activity = manager.GetObject(s_descriptor.Name, s_descriptor.Version);

            activity.Should().NotBeNull();
            activity.As <WrapperActivity>().Descriptor.Type.Should().Be(s_descriptor.Type);
        }
Exemplo n.º 6
0
        public async Task InvokeAsync_Wrapped_SetsActivity()
        {
            // arrange
            var serviceProvider = new Mock <IServiceProvider>();

            serviceProvider.Setup(m => m.GetService(typeof(TestActivity))).Returns(new TestActivity());
            var wrapper = new WrapperActivity(new TaskActivityDescriptor(typeof(TestActivity)));
            DispatchMiddlewareContext context = CreateContext(wrapper);
            var middleware = new ServiceProviderActivityMiddleware(serviceProvider.Object);

            // act
            await middleware.InvokeAsync(context, () => Task.CompletedTask);

            // assert
            TaskActivity activity = context.GetProperty <TaskActivity>();

            activity.Should().NotBeNull();
            activity.Should().Be(wrapper.InnerActivity);
            serviceProvider.Verify(m => m.GetService(typeof(TestActivity)), Times.Once);
        }
Exemplo n.º 7
0
        public void Create_ClosedGeneric_NotNull()
        {
            var descriptor = TaskActivityDescriptor.Create <TestActivity <object> >();
            var manager    = new GenericObjectManager <TaskActivity>();

            manager.Add(new ActivityObjectCreator(descriptor));
            TaskActivity activity = manager.GetObject(descriptor.Name, descriptor.Version);

            activity.Should().NotBeNull();
            activity.As <WrapperActivity>().Descriptor.Type.Should().Be(descriptor.Type);

            TaskActivity activity2 = manager.GetObject(typeof(TestActivity <int>).FullName, descriptor.Version);

            activity2.Should().BeNull();
        }