Пример #1
0
        public async Task DeleteAndSaveTest()
        {
            var membershipCard1 = new MembershipCard()
            {
                Id = 1, CreatedAt = date1, MemberId = 1
            };
            var membershipCard2 = new MembershipCard()
            {
                Id = 2, CreatedAt = date2, MemberId = 2
            };
            var membershipCards = new List <MembershipCard> {
                membershipCard1, membershipCard2
            };

            var fakeMembershipCardRepositoryMock = new Mock <IMembershipCardRepository>();
            var fakeMemberRepositoryMock         = new Mock <IMemberRepository>();

            fakeMembershipCardRepositoryMock.Setup(x => x.Delete(It.IsAny <long>())).Callback <long>(arg => membershipCards.RemoveAt(1));

            var membershipCardService = new MembershipCardService(fakeMembershipCardRepositoryMock.Object, fakeMemberRepositoryMock.Object);

            await membershipCardService.DeleteAndSave(membershipCard2.Id);

            Assert.Single(membershipCards);
            Assert.Equal(date1, membershipCards[0].CreatedAt);
        }
Пример #2
0
        public async Task <IActionResult> DeleteConfirmed(long id)
        {
            await _membershipCardService.DeleteAndSave(id);

            return(RedirectToAction(nameof(Index)));
        }