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)); }
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")); }
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); }