Example #1
0
        public void ShouldMakeDealAndReassignZones()
        {
            var buyer = new Trader
            {
                FirstName   = "Jalen",
                SecondName  = "Good",
                PhoneNumber = "(222) 730-9441",
                Balance     = 90M,
            };
            var seller = new Trader
            {
                FirstName   = "Titus",
                SecondName  = "Patel",
                PhoneNumber = "(940) 342-2889",
                Balance     = -10M,
            };
            var listing = new Listing
            {
                Name  = "Test Inc.",
                Price = 100M,
            };
            var share = new Share
            {
                Listing = listing,
                Owner   = seller,
            };

            buyer.AssignZone();
            seller.AssignZone();
            seller.Portfolio.Add(share);

            businessService.MakeDeal(buyer, seller, share);

            Assert.AreEqual(seller.Portfolio.Contains(share), false);
            Assert.AreEqual(buyer.Portfolio.Contains(share), true);
            Assert.AreEqual(share.Owner, buyer);
            Assert.AreEqual(buyer.Balance, 90 - share.Listing.Price);
            Assert.AreEqual(seller.Balance, -10 + share.Listing.Price);
            Assert.AreEqual(seller.Zone, Zone.Green);
            Assert.AreEqual(buyer.Zone, Zone.Black);
            Received.InOrder(() =>
            {
                repository.Received(1).Add(Arg.Any <Deal>());
                repository.Received(1).SaveChanges();
            });
        }