public void Delegate_type_activator_throws_if_the_underlying_function_returns_null() { // Arrange var activator = new DelegateTypeActivator(_ => null); // Act & assert Assert.Throws <CliFxException>(() => activator.CreateInstance(typeof(WithDependenciesCommand))); }
public void CreateInstance_Negative_Test(Func <Type, object> activatorFunc, Type type) { // Arrange var activator = new DelegateTypeActivator(activatorFunc); // Act & Assert var ex = Assert.Throws <CliFxException>(() => activator.CreateInstance(type)); Console.WriteLine(ex.Message); }
public void CreateInstance_Test(Func <Type, object> activatorFunc, Type type) { // Arrange var activator = new DelegateTypeActivator(activatorFunc); // Act var obj = activator.CreateInstance(type); // Assert obj.Should().BeOfType(type); }
public void Delegate_type_activator_can_initialize_a_command_using_a_custom_function() { // Arrange var activator = new DelegateTypeActivator(_ => new WithDependenciesCommand(new DependencyA(), new DependencyB())); // Act var obj = activator.CreateInstance(typeof(WithDependenciesCommand)); // Assert obj.Should().BeOfType <WithDependenciesCommand>(); }