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

            // Act
            transactionService.ChangeShare("1", "Microsoft", "hundred", "1");

            // Assert
            provider.Received(1).GetPhrase(Phrase.PriceIsLetter);
        }
Example #2
0
        public void ShouldNotChangeShareWithIncorrectOwnerID()
        {
            // Arrange
            ShareService transactionService = new ShareService(
                this.provider,
                this.shareRep,
                this.traderRep,
                this.logger);

            // Act
            transactionService.ChangeShare("1", "Microsoft", "100", "q");

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

            Trader owner = new Trader()
            {
                name    = "Evgeniy",
                surname = "Nikulin",
            };
            Share oldShare = new Share()
            {
                name     = "Ubisoft",
                price    = 50m,
                quantity = 10,
                ownerId  = 1,
            };

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

            // Act
            string shareId  = "1";
            string newName  = "Microsoft";
            string newPrice = "100";
            string ownerId  = "1";

            transactionService.ChangeShare(shareId, newName, newPrice, ownerId);

            // Assert
            shareRep.Received(1).Push(Arg.Any <Share>());
            shareRep.Received(1).SaveChanges();
            logger.Info($"Share {oldShare.name} changed to {newName} with {newPrice} price at {owner.name} {owner.surname} trader");
            provider.Received(1).GetPhrase(Phrase.Success);
        }