public void SetUp() { var validatorMock = new Mock<IValidator>(); validatorMock.Setup(v => v.TryValidate(It.IsAny<Profile>())) .Returns(true); var repoMock = new Mock<IRepository<Profile, int>>(); repoMock.Setup(m => m.Add(It.IsAny<Profile>())) .Returns(new Profile { Id = 65, FirstName = "Joe", LastName = "Smith", EmailAddress = "*****@*****.**" }); _interactor = new AddProfileInteractor(repoMock.Object, validatorMock.Object) { FirstName = "Joe", LastName = "Smith", EmailAddress = "*****@*****.**" }; _result = _interactor.Execute(); }
public void returns_null() { var validatorMock = new Mock<IValidator>(); validatorMock.Setup(v => v.TryValidate(It.IsAny<Profile>())) .Returns(false); var repoMock = new Mock<IRepository<Profile, int>>(); var interactor = new AddProfileInteractor(repoMock.Object, validatorMock.Object) { FirstName = "Joe", LastName = "Smith", EmailAddress = "*****@*****.**" }; Assert.IsNull(interactor.Execute()); }