コード例 #1
0
        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));
        }
コード例 #2
0
        private MyAbstractCommandFactory GivenAFactoryWithMyCommand()
        {
            IRestClient restClient = new RestClient();

            credentials = new Credentials("url", "token", "");
            var factory = new MyAbstractCommandFactory(restClient);

            // given a factory with MyCommand
            return(factory);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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");
        }
コード例 #5
0
        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");
        }