Beispiel #1
0
        public async Task ShouldPublishFriendReferralEvent_WhenValidDataIsPassed()
        {
            // Arrange
            var fixture    = new FriendReferralHistoryServiceTestsFixture();
            var referredId = Guid.NewGuid();

            // Act;
            await fixture.Service.CreateAsync(fixture.CustomerId, fixture.CampaignId, fixture.Email, fixture.FullName);

            // Assert
            fixture.FriendReferralHistoryRepositoryMock.Verify(x =>
                                                               x.CreateAsync(
                                                                   It.Is <ReferralFriend>(c => c.ReferrerId == fixture.CustomerId)));
        }
Beispiel #2
0
        public async Task ShouldNotPublishFriendReferralEvent_WhenNoCustomerIsFoundForReferralCode()
        {
            // Arrange
            var fixture = new FriendReferralHistoryServiceTestsFixture();

            fixture.CustomerProfileClientMock.Setup(c => c.CustomerProfiles.GetByCustomerIdAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .ReturnsAsync(() => new CustomerProfileResponse
            {
                ErrorCode = CustomerProfileErrorCodes.CustomerProfileDoesNotExist
            });

            var referredId = Guid.NewGuid();

            // Act;
            // Assert

            await Assert.ThrowsAsync <CustomerDoesNotExistException>(async() =>
                                                                     await fixture.Service.CreateAsync(referredId, fixture.CampaignId, fixture.Email, fixture.FullName));
        }
Beispiel #3
0
        public async Task ShouldGetAllPurchaseReferrals_WhenCustomerIdIsPassed()
        {
            // Arrange
            var fixture = new FriendReferralHistoryServiceTestsFixture();

            var friendReferralHistory = new FriendReferralHistory
            {
                ReferrerId = Guid.NewGuid().ToString()
            };

            fixture.FriendReferralHistoryRepositoryMock.Setup(c => c.GetAllReferralsForCustomerAsync(It.IsAny <Guid>()))
            .ReturnsAsync(friendReferralHistory);


            // Act;
            var result = await fixture.Service.GetAllReferralsForCustomerAsync(Guid.NewGuid());

            // Assert
            Assert.Equal(friendReferralHistory, result);
        }