예제 #1
0
        public async void VerifyExistItems()
        {
            var friends = _mapper.Map <IEnumerable <Friend> >(FriendTestData.GetAll());

            _friendMock.Setup(x => x.GetAll()).ReturnsAsync(friends);

            var dbFriends = await _friendApplication.GetAll();

            Assert.True(dbFriends.Count() == 3);
        }
예제 #2
0
        public async void VerifyDeleteItem()
        {
            var friends = _mapper.Map <IEnumerable <Friend> >(FriendTestData.GetAll());

            _friendMock.Setup(x => x.Delete(It.IsAny <int>())).ReturnsAsync(true);

            var itemDelete = await _friendApplication.Delete(1);

            _friendMock.Verify(x => x.Delete(It.IsAny <int>()), Times.Once);
        }
예제 #3
0
        public async void VerifyCreateItemWithError()
        {
            var friendVM = FriendTestData.Get();

            var friends = _mapper.Map <IEnumerable <Friend> >(FriendTestData.GetAll());

            _friendMock.Setup(x => x.GetAll()).ReturnsAsync(friends);

            var newFriend = await _friendApplication.Create(friendVM);

            var validation = new FriendValidation(_friendApplication).Validate(friendVM);

            Assert.False(validation.IsValid);

            Assert.True(validation.Errors.Where(x => x.ErrorMessage == "Já possui um amigo cadastrado com esse email.").Any());
        }