DoInstead Not working

0 Answers 204 Views
API Code Coverage General Discussions Private Accessor
Ope
Top achievements
Rank 1
Ope asked on 03 Mar 2022, 05:27 PM

I want the Mock to return the SQL statement and Not execute the statement. This is what i have done but it keeps running the "connection.execution(SQL)".  

                         

 

string SQL = "";

            Mock.Arrange(() => connection.Execute(Arg.AnyString, null, null, null, null)).DoInstead((string arg1) => { SQL = arg1; }).IgnoreInstance().Returns(1);



            WebApiProject.Controllers.DeleteController dc = new WebApiProject.Controllers.DeleteController();
           
            dc.Post(mockedDeleteObject);

            Assert.IsTrue(SQL == $"DELETE FROM TEST WHERE 1=1");

 

 

Post{

                string SQL;
                SQL = $"delete from {TableName}  where  {WhereClause} ";

                con.Execute(SQL,parameters );}

 

 

 

But it keeps running the sql executable statement

 

 

 

Ivo
Telerik team
commented on 08 Mar 2022, 09:45 AM

Hello Ope, I am afraid that having just a few code fragments is not enough and it is really hard to be identified the reason for the failure. Please provide a minimal sample project that could easily reproduce the issue.

No answers yet. Maybe you can help?

Tags
API Code Coverage General Discussions Private Accessor
Asked by
Ope
Top achievements
Rank 1
Share this question
or