Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using AutoMoq;
- using NUnit.Framework;
- namespace TestProject1
- {
- [TestFixture]
- public class UnitTest1
- {
- private AutoMoqer mocker;
- private SomeController controller;
- private const string Id = "the id";
- [SetUp]
- public void Setup()
- {
- mocker = new AutoMoqer();
- var profile = new Profile();
- controller = mocker.Create<SomeController>();
- mocker.GetMock<IProfilerGetter>().Setup(p => p.Get(Id)).Returns(profile);
- }
- [Test]
- public void CanAMockGeneratedByAutomoqBeCalledOnce()
- {
- var p1 = controller.Get(Id);
- Assert.IsNotNull(p1);
- }
- [Test]
- public void CanAMockGeneratedByAutomoqBeCalledTwice()
- {
- var p2 = controller.Get(Id);
- Assert.IsNotNull(p2);
- }
- }
- public class SomeController
- {
- private readonly IProfilerGetter profilerGetter;
- public SomeController(IProfilerGetter profilerGetter)
- {
- this.profilerGetter = profilerGetter;
- }
- public Profile Get(string id)
- {
- return profilerGetter.Get(id);
- }
- }
- public interface IProfilerGetter
- {
- Profile Get(string id);
- }
- public class Profile
- {
- }
- }
Add Comment
Please, Sign In to add comment