Exemplo n.º 1
0
        public void Contructor_Tests()
        {
            // Arrange
            var userId   = new UserId();
            var playerId = new PlayerId();

            var timestamp = new UtcNowDateTimeProvider();

            // Act
            var credential = new Credential(
                userId,
                Game.LeagueOfLegends,
                playerId,
                timestamp);

            // Assert
            credential.UserId.Should().Be(userId);
            credential.UserId.Should().NotBeNull();

            credential.Game.Should().Be(Game.LeagueOfLegends);
            credential.Game.Should().NotBeNull();

            credential.PlayerId.Should().Be(playerId);
            credential.PlayerId.Should().NotBeNull();

            credential.Timestamp.Should().Be(timestamp.DateTime);
        }
Exemplo n.º 2
0
 // Francis: Refactor nécessaire, FormatCurrencyByType peux throw un exception avant que GetDefault peux throw la sienne. Bref, l'exception
 // de GetDefaultDescription est impossible a throw parce que Format la throw avant.
 public TransactionBuilder(TransactionType type, Currency currency)
 {
     Type        = type;
     Currency    = FormatCurrencyByType(type, currency);
     Description = GetDefaultDescriptionByType(type, currency);
     Provider    = new UtcNowDateTimeProvider();
     Metadata    = null;
 }
Exemplo n.º 3
0
        public void ConstructorWithProvider_WhenNoType_ShouldThrowInvalidOperationException()
        {
            // Arrange
            var provider = new UtcNowDateTimeProvider();

            // Act Assert
            var action = new Action(() => new TransactionBuilder(TransactionType.All, new Token(100000)).WithProvider(provider).Build());

            action.Should().Throw <InvalidOperationException>();
        }
Exemplo n.º 4
0
        public void Cancel_WhenValid_ShouldCreateDomainEvent()
        {
            // Arrange
            var promotion  = this.GenerateValidPromotion();
            var cancelTime = new UtcNowDateTimeProvider();

            // Act
            promotion.Cancel(cancelTime);

            // Assert
            promotion.CanceledAt.Should().Be(cancelTime.DateTime);
        }
Exemplo n.º 5
0
        public void DescriptionToString_ShouldBeSame()
        {
            // Arrange
            var currency    = Money.Fifty;
            var description = new TransactionDescription("Test");
            var type        = TransactionType.Deposit;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(currency, description, type, provider);

            // Act Assert
            transaction.Description.ToString().Should().Be("Test");
        }
Exemplo n.º 6
0
        public void Transaction_WithConstructor_ShouldBeValid()
        {
            // Arrange
            var currency = Money.Fifty;
            var type     = TransactionType.Deposit;
            var provider = new UtcNowDateTimeProvider();

            // Act
            var transaction = new TransactionBuilder(type, currency).WithProvider(provider).Build();

            // Assert
            transaction.Timestamp.Should().Be(provider.DateTime);
            transaction.Currency.Should().Be(currency);
            transaction.Type.Should().Be(type);
            transaction.Status.Should().Be(TransactionStatus.Pending);
        }
Exemplo n.º 7
0
        public void MarkAsFailed_StatusPending_ShouldBeStatusFailed()
        {
            // Arrange
            var currency    = Money.Fifty;
            var description = new TransactionDescription("Test");
            var type        = TransactionType.Deposit;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(
                currency,
                description,
                type,
                provider);

            // Act
            transaction.MarkAsFailed();

            // Assert
            transaction.Status.Should().Be(TransactionStatus.Failed);
        }
Exemplo n.º 8
0
        public void MarkAsCanceled_WhenTransactionStatusPending_ShouldBeStatusSucceded()
        {
            // Arrange
            var currency    = Money.Twenty;
            var description = new TransactionDescription("Transaction to cancel");
            var type        = TransactionType.Withdraw;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(
                currency,
                description,
                type,
                provider);

            // Act
            transaction.MarkAsCanceled();

            // Assert
            transaction.Status.Should().Be(TransactionStatus.Canceled);
        }
Exemplo n.º 9
0
        public void Price_WithTransactionFromToken_ShouldBePriceMoney()
        {
            // Arrange
            var currency    = Token.FiftyThousand;
            var description = new TransactionDescription("Price to check");
            var type        = TransactionType.Deposit;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(
                currency,
                description,
                type,
                provider);

            // Act Assert
            transaction.Price.Should().NotBeNull();
            var price = transaction.Price;

            price.Amount.Should().Be(500);
            price.Type.Should().Be(CurrencyType.Money);
        }
Exemplo n.º 10
0
        public void Price_WithTransactionFromMoney_ShouldBePriceMoney()
        {
            // Arrange
            var currency    = Money.Twenty;
            var description = new TransactionDescription("Price to check");
            var type        = TransactionType.Withdraw;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(
                currency,
                description,
                type,
                provider);

            // Act Assert
            transaction.Price.Should().NotBeNull();
            var price = transaction.Price;

            price.Amount.Should().Be(20);
            price.Type.Should().Be(CurrencyType.Money);
        }
Exemplo n.º 11
0
        public void MarkAsFailed_WhenTransactionStatusSucceeded_ShouldThrowInvalidOperationException()
        {
            // Arrange
            var currency    = Money.Fifty;
            var description = new TransactionDescription("Test");
            var type        = TransactionType.Deposit;
            var provider    = new UtcNowDateTimeProvider();

            var transaction = new Transaction(
                currency,
                description,
                type,
                provider);

            transaction.MarkAsSucceeded();

            // Act
            var action = new Action(() => transaction.MarkAsFailed());

            // Assert
            action.Should().Throw <InvalidOperationException>();
        }