Beispiel #1
0
 public void Handle(AcceptingPurchaseOrderItemLine notification)
 {
     if (notification.Item.Type == ItemLineType.Membership && notification.Item.Category == ItemLineCategory.Video)
     {
         var membership = _Repository.Get(notification.CustomerId);
         if (membership == null)
         {
             membership = VideoClubMembership.Create(notification.CustomerId);
         }
     }
 }
        public void VideoClubServiceActivateMembership()
        {
            AcceptingPurchaseOrderItemLine acceptingPurchaseOrderItemLine = new AcceptingPurchaseOrderItemLine
            {
                CustomerId = 3344656,
                Item       = new ItemLineRequest {
                    Description = "Video Club Membership", Type = ItemLineType.Membership, Category = ItemLineCategory.Video
                }
            };
            ActivatedMembership activatedMembership = new ActivatedMembership
            {
                Activated = true
            };

            var mockMediator = new Mock <IMediator>();
            IVideoClubMembershipRepository videoClubMembershipRepository = GetFakeVideoClubMembershipRepository();

            var sut = new VideoClubService(mockMediator.Object, videoClubMembershipRepository);

            sut.Handle(acceptingPurchaseOrderItemLine);

            videoClubMembershipRepository.Get(3344656).ShouldNotBeNull();
        }
        private bool CustomerHasMembership(int customerId)
        {
            var hasMembership = _Repository.Get().Any(bcm => bcm.Id == customerId);

            return(hasMembership);
        }