Jump to content

Recommended Posts

Posted

C# code rasanu .. Maa tl antadu.. "It works but cannot be unit tested using Moq Framework.

So please write a code that is testable by moq framework .. "

Naku poorthi ga ardham kaaledhu .. But he I heard some words like "decouple the code and inject the dependency " ani annadu ...

 

Please help bhaiyyas

Posted

Malli first nunchi rayi ani Dani ardam

 

 

Implementation code and Logic code already undhi.. kaani.. i dont know what he want in terms of decoupling and inject dependency using interface

Posted

obv. nuvu classes ni direct ga instantiate chesi use chestunnav..so there is a tight dependency there..interface use chesi make your code aware of interface method and not the actual method ani dani ardam 

C# code rasanu .. Maa tl antadu.. "It works but cannot be unit tested using Moq Framework.

So please write a code that is testable by moq framework .. "

Naku poorthi ga ardham kaaledhu .. But he I heard some words like "decouple the code and inject the dependency " ani annadu ...

 

Please help bhaiyyas

 

Posted

obv. nuvu classes ni direct ga instantiate chesi use chestunnav..so there is a tight dependency there..interface use chesi make your code aware of interface method and not the actual method ani dani ardam 

Exactly.. adhey annadu... I am not very good at coding in this level

 

My code ..

 

Class A ,Class B, Class C unnayi

 

ClassA ca= new ClassA();

 

ca.Copy();

 

ClassB cb= new ClassB();

 

cb.Copy();

 

ClassC cc= new Classc();

 

cc.Copy();

 

 

copy method ni read and write ga rendu methods ga marchukommannadu.. sqlconnection undhi method lo , nv dependency pettesav sqlconnection ki ani.. 

I see what he is trying to convey but naku idea ravatledhu

 
Posted

naaku full knowledge ledhu.yet.. but you have to use Ninject/MEF/autofac  to get the object of the class and only interface vadali in the actual code..look at examples(there are bunch) and take help of another dev

Posted

naaku full knowledge ledhu.yet.. but you have to use Ninject/MEF/autofac  to get the object of the class and only interface vadali in the actual code..look at examples(there are bunch) and take help of another dev

4s086h.gif

Posted

 

naaku full knowledge ledhu.yet.. but you have to use Ninject/MEF/autofac  to get the object of the class and only interface vadali in the actual code..look at examples(there are bunch) and take help of another dev

4s086h.gif

 

pilladiki help cheyochuga u nasty vuncle 4s086h.gif

Posted


naaku full knowledge ledhu.yet.. but you have to use Ninject/MEF/autofac to get the object of the class and only interface vadali in the actual code..look at examples(there are bunch) and take help of another dev

4s086h.gif
suruku
Posted

thesi 10gu annadu .... .NET DOI frameworks ento naaku thelisi so no furthur comments bahyaaaa

 

Exactly.. adhey annadu... I am not very good at coding in this level

 

My code ..

 

Class A ,Class B, Class C unnayi

 

ClassA ca= new ClassA();

 

ca.Copy();

 

ClassB cb= new ClassB();

 

cb.Copy();

 

ClassC cc= new Classc();

 

cc.Copy();

 

 

copy method ni read and write ga rendu methods ga marchukommannadu.. sqlconnection undhi method lo , nv dependency pettesav sqlconnection ki ani.. 

I see what he is trying to convey but naku idea ravatledhu

 

 

 

Posted

just outline and naku telisindi rasa..hope this helps i dont have a strong command on this so get a second opinion

public interface IJambalHeart
{
    void Read(string conn);
    void Write(string conn);
}

public class ClassA: IJambalHeart
{
   public void Read(string conn)
   {
	 //ne istam
   }
   public void Write(string conn)
   {
	 //ne istam
   }
}

alage classB, class ClassA

public class SomeClass
{
	private readonly IJambalHeart jambal;
	
	public SomeClass(IJambalHeart jambal)
	{
		this.jambal = jambal;
	}
	
	//read method calling
	
	public void ReadMethod(string conn)
	{
		//here jambal is class
		jambal.Read(conn);
	}
	
	public void WriteMethod(string conn)
	{
		//here jambal is class
		jambal.Write(conn);
	}
}


from where you are calling just inst interface
IJambalHeart jambal = new ClassA(); //classc whatever you want
SomeClass cl = new SomeClass(jambal);
cl.ReadMethod(connection parameter);
c1.WriteMethod(connection para);

 

Exactly.. adhey annadu... I am not very good at coding in this level

 

My code ..

 

Class A ,Class B, Class C unnayi

 

ClassA ca= new ClassA();

 

ca.Copy();

 

ClassB cb= new ClassB();

 

cb.Copy();

 

ClassC cc= new Classc();

 

cc.Copy();

 

 

copy method ni read and write ga rendu methods ga marchukommannadu.. sqlconnection undhi method lo , nv dependency pettesav sqlconnection ki ani.. 

I see what he is trying to convey but naku idea ravatledhu

 

 

 

×
×
  • Create New...