Samuel David
Member
- Joined
- Nov 29, 2022
- Messages
- 9
- Programming Experience
- Beginner
Hello Everyone,
I am writing unit test cases(using xunit) for DAL methods(which are calling stored procedures and some direct sql commands and not returning methods). How can I mock the results coming from db in unit tests.
Please let me know sample references or suggestions.
Thanks,
Sam
I am writing unit test cases(using xunit) for DAL methods(which are calling stored procedures and some direct sql commands and not returning methods). How can I mock the results coming from db in unit tests.
sample code:
public class Notification : Base, INotificationBal
{
public void InsertNotification(NotificationType notif)
{
using(var con=GetConnction())
{
using(var command = CreatSqlCommand(con, "sp_InsertNotifDetails"))
{
//notif.NotificationType=1, notif.NotificationName="Mobile"
command.SetParamsValues(
("@NotificationType", notif.NotificationType),
("@NotificationName", notif.NotificationName)
));
command.ExecuteNonQuery());
}
}
}
}
Please let me know sample references or suggestions.
Thanks,
Sam
Last edited: