asp.net mvc - How to mock a function that returns a GUID using Moq.Mock() -


How can I write a mock for a method that gives GUID in the .NET mvc unit test. Eg: I have a service class that adds objects to DB and gives a GUID. I want to be fake in the unit test.

Something like this should work for you:

  fake .setup (Foo = & gt; foo.AddObject (this. Any such & lt; some object & gt; ())). Returns (Guid.NewGuid ());    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -