public void AllPaymentsValidator_HasItems_All_Success() { //Mock var mock = new Mock <IUserRepository>(); mock.Setup(x => x.GetItemAsync(It.IsAny <Expression <Func <User, bool> > >())).Returns(Task.FromResult(new User())); //Arrange var manager = new AllPaymentsValidator(mock.Object, _log); //Act var list = manager.GetValidatorsResult(_filter).Result.ToList(); //Assert Assert.IsTrue(manager.ReturnObject != null); Assert.IsTrue(list.Any()); foreach (var result in list.Select(item => item.Invoke())) { Assert.IsTrue(result.StatusCode == StatusCode.Success); } }
public void AllPaymentsValidator_PaymentsFilter_NullValue_Failed() { //Mock var mock = new Mock <IUserRepository>(); mock.Setup(x => x.GetItemAsync(null)).Returns(Task.FromResult <User>(null)); //Arrange var manager = new AllPaymentsValidator(mock.Object, _log); //Act var list = manager.GetValidatorsResult(null).Result.ToList(); var results = list.Select(item => item.Invoke()).ToList(); //Assert Assert.IsTrue(manager.ReturnObject == null); Assert.IsTrue(results.Any()); Assert.IsTrue(results.Any(x => x.StatusCode == StatusCode.Failed)); foreach (var result in results) { Assert.IsTrue(result.StatusCode == StatusCode.Failed); Assert.AreEqual(result.ErrorCode, ErrorCode.NoAuthorized); } }