Hi, all. I am using Entity Framework and decided to do some dependency injection in order to make my functions more testable. This seemed to bring up a few questions that I found difficult to solve. I guess the difficult part is figuring out the best practice of doing this, rather. So, to cut it short, I'm using Moq for mocking up the context class and the datasets. The class looks something like this: public class Auth { private dbcontext _ctx; public Auth(dbcontext ctx) { _ctx = ctx; } public bool Authenticate(string usr, string psw) { var a = _ctx.accounts.Where( …

Member Avatar
+0 forum 0

I have a method that returns void. say: Public void CreateRectangle(double z, double y, IRectangle rectObj) { Vector3d recPos1 = new Vector3d() recPos1.X = 0; recPos1.Y = some double vale; Vector3d recPos2 = new Vector3d() recPos2.X = some double value; recPos2.Y = 0; rectObj.SetVectors(recPos1, recPos2); } now, in my unit test i just want to verify that SetVectors() method has been called on object rectObj. I have written a moq unit test but it fails. My method looks like this: [Test(Description = "")] public void TestCreateRectangle() { double xPos = default(double); double yPos = default(double); myClass objMyClass = new myClass(); …

Member Avatar
Member Avatar
+0 forum 1

Hi, I am working on a component based application. I have a method that does some calculation and returns nothing. say: public void DoSomething(int x, int y) { // do something } How to write testing for it. I can pass some dummy x,y values. But how and what we can Assert in the unit test project. Any help would be appreciated. Thanks. Regards

Member Avatar
Member Avatar
+0 forum 2

The End.