Exemple #1
0
        public void ShouldAddShare()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            Trader owner = new Trader()
            {
                name    = "Evgeniy",
                surname = "Nikulin",
            };

            traderRep.GetTrader(Arg.Any <int>()).Returns(owner);

            // Act
            string shareName = "Microsoft";
            string price     = "100";
            string quantity  = "1";
            string ownerId   = "1";

            transactionService.AddShare(shareName, price, quantity, ownerId);

            // Assert
            shareRep.Received(1).Push(Arg.Any <Share>());
            shareRep.Received(1).SaveChanges();
            logger.Info($"{quantity} of {shareName} shares with {price} price is added to {owner.name} {owner.surname} trader");
            provider.Received(1).GetPhrase(Phrase.Success);
        }
Exemple #2
0
        public void ShouldNotAddShareWithQuantityIsLetter()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            // Act
            transactionService.AddShare("Microsoft", "100", "ten", "1");

            // Assert
            provider.Received(1).GetPhrase(Phrase.QuantityIsLetter);
        }
Exemple #3
0
        public void ShouldNotAddShareWithIncorrectID()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            // Act
            transactionService.AddShare("Microsoft", "100", "10", "q");

            // Assert
            provider.Received(1).GetPhrase(Phrase.IncorrectID);
        }