public void CreateHandler_Valid_ExpectInstantiated() { MyAbstractCommandFactory factory = GivenAFactoryWithMyCommand(); var myCommand = new MyCommand(null); var myCommandHandler = factory.CreateHandler(myCommand); Assert.IsNotNull(myCommandHandler, "should be created, as a valid interface is specified"); Assert.IsInstanceOfType(myCommandHandler, typeof(MyCommandHandler)); }
private MyAbstractCommandFactory GivenAFactoryWithMyCommand() { IRestClient restClient = new RestClient(); credentials = new Credentials("url", "token", ""); var factory = new MyAbstractCommandFactory(restClient); // given a factory with MyCommand return(factory); }
public void CreateCommand_Valid_ExpectInstantiated() { MyAbstractCommandFactory factory = GivenAFactoryWithMyCommand(); // when we request to create an instance of that command var command = factory.CreateCommand <IMyCommand>(credentials); //then we expect it to be there Assert.IsNotNull(command, "should be created, as a valid interface is specified"); Assert.IsInstanceOfType(command, typeof(MyCommand)); }
public void CreateCommand_InValid_ExpectException() { MyAbstractCommandFactory factory = GivenAFactoryWithMyCommand(); try { var command = factory.CreateCommand <ISillyCommand>(credentials); } catch (ArgumentException) { return; } Assert.Fail("should not be created, as an invalid interface is specified"); }
public void CreateHandler_InValid_ExpectException() { MyAbstractCommandFactory factory = GivenAFactoryWithMyCommand(); try { var myCommand = new MySillyCommand(null); var myCommandHandler = factory.CreateHandler(myCommand); } catch (ArgumentException) { return; } Assert.Fail("should not be created, as an ivalid interface is specified"); }