예제 #1
0
        public async Task CreateChallengeAsync_ShouldBeOfTypeValidationResultWithErrors()
        {
            // Arrange
            TestMock.ChallengePayoutStrategy.Setup(payout => payout.GetChallengePayout(It.IsAny <ChallengePayoutEntries>(), It.IsAny <EntryFee>())).Verifiable();

            TestMock.ChallengePayoutFactory.Setup(payout => payout.CreateInstance()).Returns(TestMock.ChallengePayoutStrategy.Object).Verifiable();

            var service = new ChallengeService(TestMock.ChallengePayoutFactory.Object, TestMock.ChallengeRepository.Object);

            var bucket = new ChallengePayoutBucket(ChallengePayoutBucketPrize.Consolation, ChallengePayoutBucketSize.Individual);

            var buckets = new ChallengePayoutBuckets(
                new List <ChallengePayoutBucket>
            {
                bucket
            });

            var payoutEntries = new ChallengePayoutEntries(buckets);

            // Act
            var result = await service.CreateChallengeAsync(new ChallengeId(), payoutEntries, new EntryFee(5000, CurrencyType.Token));

            // Assert
            result.Should().BeOfType <DomainValidationResult <IChallenge> >();

            result.Errors.Should().NotBeEmpty();

            TestMock.ChallengePayoutStrategy.Verify(payout => payout.GetChallengePayout(It.IsAny <ChallengePayoutEntries>(), It.IsAny <EntryFee>()), Times.Once);

            TestMock.ChallengePayoutFactory.Verify(payout => payout.CreateInstance(), Times.Once);
        }
 public static ChallengePayoutBucketModel ToModel(this ChallengePayoutBucket challengePayoutBucket)
 {
     return(new ChallengePayoutBucketModel
     {
         Size = challengePayoutBucket.Size,
         PrizeCurrency = challengePayoutBucket.Prize.Type.Value,
         PrizeAmount = challengePayoutBucket.Prize.Amount
     });
 }
예제 #3
0
        public void GetHashCode_ShouldNotBeZero()
        {
            // Arrange
            const int amount = 5;
            var       type   = CurrencyType.Money;
            var       bucket = new ChallengePayoutBucket(new ChallengePayoutBucketPrize(amount, type), ChallengePayoutBucketSize.Individual);

            // Act Assert
            bucket.GetHashCode().Should().NotBe(0);
        }
예제 #4
0
        public void ToString_ShouldContainPrizeAndType()
        {
            // Arrange
            const int amount = 5;
            var       type   = CurrencyType.Money;
            var       bucket = new ChallengePayoutBucket(new ChallengePayoutBucketPrize(amount, type), ChallengePayoutBucketSize.Individual);

            // Act
            var result = bucket.ToString();

            // Assert
            result.Should().Contain(amount.ToString(), type.ToString());
        }
        public void GetPayout_WithEntries_ShouldNotBeNull()
        {
            // Arrange
            var payoutStrategy = new DefaultChallengePayoutStrategy();

            var bucket = new ChallengePayoutBucket(ChallengePayoutBucketPrize.Consolation, ChallengePayoutBucketSize.Individual);

            var buckets = new ChallengePayoutBuckets(
                new List <ChallengePayoutBucket>
            {
                bucket
            });

            var payoutEntries = new ChallengePayoutEntries(buckets);

            // Act
            var payout = payoutStrategy.GetChallengePayout(payoutEntries, new EntryFee(5000, CurrencyType.Token));

            // Assert
            payout.Should().NotBeNull();
        }