Ejemplo n.º 1
0
        public void TestCustomCommand_Detach()
        {
            var fact      = Substitute.For <CustomCommandFactory>();
            var receiver  = Substitute.For <ICustomReceiver>();
            var validator = Substitute.For <ICustomValidator>();

            validator.IsValidArgument(receiver).Returns <bool>(true);
            CustomCommand cmd = fact.Create(receiver, validator) as CustomCommand;

            Assert.IsNotNull(cmd);
            Assert.IsNotNull(cmd.Receiver);
            Assert.AreSame(receiver, cmd.Receiver);
            Assert.IsNotNull(cmd.Validator);
            Assert.AreSame(validator, cmd.Validator);

            cmd.Dettach();
            Assert.IsNotNull(cmd);
            Assert.IsNull(cmd.Receiver);
            Assert.IsNull(cmd.Validator);
        }