Created
September 9, 2011 11:45
-
-
Save dtchepak/1206005 to your computer and use it in GitHub Desktop.
Trying to replicate reported problem with NSub 1.2 and pure virtual classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class NHibernatishExample { | |
public interface IRepository { SampleEntity Get(int id); } | |
public class SampleEntity { | |
public virtual int Id { get; set; } | |
public virtual string Name { get; set; } | |
} | |
public class SomeService { | |
private readonly IRepository _repository; | |
public SomeService(IRepository repository) { _repository = repository; } | |
public SampleEntity DoSomething() { | |
return _repository.Get(4); | |
} | |
} | |
[Test] | |
public void DoSomething() | |
{ | |
var mockRepository = Substitute.For<IRepository>(); | |
var fakeEntity = new SampleEntity { Id = 4, Name = "Sample" }; | |
mockRepository.Get(4).Returns(fakeEntity); | |
var result = new SomeService(mockRepository).DoSomething(); | |
Assert.That(result.Id, Is.EqualTo(4)); | |
Assert.That(result.Name, Is.EqualTo("Sample")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment