DoInstead Not working

1 Answer 66 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.

1 Answer, 1 is accepted

Sort by
0
faul
Top achievements
Rank 1
Iron
answered on 04 Jul 2022, 09:53 AM
Provide code with missing data 
fall guys

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