示例#1
0
            public void ShouldInstantiateRunnable_WhenConstructorAcceptsServiceFactory()
            {
                // Arrange
                var serviceFactory = new ServiceFactoryStub();
                var underTest      = new DefaultRunnableFactory(new[] { typeof(TestRunnableWithServiceFactory) }, serviceFactory: serviceFactory);

                // Act
                var result = underTest.Create(nameof(TestRunnableWithServiceFactory), Enumerable.Empty <KeyValuePair <String, Object> >()) as TestRunnableWithServiceFactory;

                // Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.ServiceFactory, Is.SameAs(serviceFactory));
            }
示例#2
0
            public void ShouldInstantiateRunnable_WhenDefaultConstructorIsAvailable()
            {
                // Arrange
                var actualArguments = new Dictionary <String, Object>
                {
                    ["value"]       = "test",
                    ["description"] = "some description"
                };
                var underTest = new DefaultRunnableFactory(new[] { typeof(TestRunnable) });

                // Act
                var result = underTest.Create(nameof(TestRunnable), actualArguments) as TestRunnable;

                // Assert
                Assert.That(result, Is.Not.Null);
                Assert.That(result.Value, Is.EqualTo("test"));
                Assert.That(result.Description, Is.EqualTo("some description"));
            }
示例#3
0
            public void ShouldConvertDoubleToIntegerValue_WhenParameterTypeIsInt32AndIntegerValueConverterIsPassed()
            {
                // Arrange
                var actualArguments = new Dictionary <String, Object>
                {
                    ["number"] = 10.0
                };
                var valueConverter = Substitute.For <IntegerValueConverter>();
                var underTest      = new DefaultRunnableFactory(new[] { typeof(TestRunnable) }, valueConverter);

                // Act
                var result = underTest.Create(nameof(TestRunnable), actualArguments) as TestRunnable;

                // Assert
                Assert.That(result.Number, Is.EqualTo(10));
                valueConverter.Received(1).CanConvert(10.0, typeof(Int32));
                valueConverter.Received(1).Convert(10.0);
            }