Пример #1
0
        public void Notify(/*string message,*/ ISon selectedSon) //method dependency injection
        {
            if (selectedSon /*Son*/ == null)
            {
                Console.WriteLine("Dad needs help");
            }

            //son.Help(message);
            //selectedSon.Help(message);
            //Son.Help(message);
        }
Пример #2
0
        [Test] public void CanCreateProxy()
        {
            var all  = new Dictionary <MemberInfo, int>();
            var type = typeof(ISon);
            var i    = type.GetInterfaces();

            foreach (var parent in i)
            {
                GetMemembers(parent, all);
            }
            GetMemembers(type, all);
            ISon mock = MockRepository.GenerateStub <ISon>();
            var  son  = NotifyPropertyChangeFactory.GetProxy(mock);

            mock.Name = "Son";
            mock.Stub(m => m.Job).Return("NoJob");
            Assert.That(son.Name, Is.EqualTo(mock.Name));
            Assert.That(son.Age, Is.EqualTo(10));
            Assert.That(son.Job, Is.EqualTo("NoJob"));
            Assert.That(((IFather)son).Job, Is.EqualTo("NoJob"));
            Assert.That(((IMother)son).Job, Is.EqualTo("NoJob"));
            Factory.SaveAssembly();
        }
Пример #3
0
        //Constructor
        //1. Example of constructor injection
        //Dad is injecting what son he wants to call in the constructor
        //public Dad(ISon selectedSon)
        //{
        //    son = selectedSon;
        //}


        //2. Example of method injection
        public void Notify(ISon selectedSon, string message)
        {
            selectedSon.Help(message);
        }
Пример #4
0
 public Dad(ISon selectedSon) //ctor dependency injection
 {
     son = selectedSon;
 }
Пример #5
0
 public static void Notify(ISon son, string message)
 {
     son.Help(message);
 }
Пример #6
0
 public Dad(ISon selectedSon)
 {
     _son = selectedSon;
 }
 public string NotifySon(ISon Cson, string Message)
 {
     return(Cson.Help(Message));
 }
 public string GetHelp(ISon Cson, string Message)
 {
     return(Cson.Help(Message));
 }
 public Dad(ISon SelectedSon)
 {
     son = SelectedSon;
 }