public void Test_GetUserInfo_ReturnsData()
        {
            var userid = 1;

            var userDTO = new UserEntity
            {
                id         = 1,
                first_name = "Normal",
                last_name  = "User",
                usertype   = 1,

                UserType = new UserTypeEntity
                {
                    type     = "NORMAL USER",
                    Discount = new DiscountEntity
                    {
                        discount = null
                    }
                }
            };

            repositoryMock.Setup(p => p.GetUserInfo(userid)).Returns(userDTO);

            LoginService loginService = new LoginService(repositoryMock.Object);
            var          result       = loginService.GetUserInfo(userid);

            Assert.NotNull(result);
            Assert.True(userDTO.Equals(result));
        }
        public void Test_Valid_Credentials()
        {
            var credentials = new CredentialsViewModel
            {
                UserName = "******",
                Password = "******"
            };

            var userDTO = new UserEntity
            {
                id         = 1,
                first_name = "Normal",
                last_name  = "User",
                usertype   = 1,
                user_name  = "user1",
                password   = "******"
            };

            repositoryMock.Setup(p => p.LoginAsync(credentials.UserName, credentials.Password)).Returns(userDTO);

            LoginService loginService = new LoginService(repositoryMock.Object);
            var          result       = loginService.LoginAsync(credentials);

            Assert.NotNull(result);
            Assert.True(userDTO.Equals(result));
        }
        public override bool FullEquals(RequestListFilterEntity other)
        {
            if (other == null)
            {
                return(false);
            }

            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other != null &&
                   StartDateTime == other.StartDateTime &&
                   Nullable.Equals(StopDateTime, other.StopDateTime) &&
                   UserEntity.Equals(ResponseUser, other.ResponseUser) &&
                   UserEntity.Equals(CreatorUser, other.CreatorUser) &&
                   AppEntity.Equals(Application, other.Application) &&
                   OrgEntity.Equals(Organization, other.Organization) &&
                   string.Equals(StatusIdList, other.StatusIdList) &&
                   string.Equals(TagIdList, other.TagIdList) &&
                   string.Equals(Subject, other.Subject) &&
                   string.Equals(Comments, other.Comments) &&
                   string.Equals(Contact, other.Contact) &&
                   string.Equals(RequestId, other.RequestId));
        }
        public void RunTradingSimulation()
        {
            TradingSimulation tradingSimulation = new TradingSimulation(dbContext);
            UserEntity        seller            = tradingSimulation.ChooseARandomUser();
            UserEntity        customer          = tradingSimulation.ChooseARandomUser();

            while (seller.Equals(customer))
            {
                customer = tradingSimulation.ChooseARandomUser();
            }

            UserAndSharesEntity sellerSharesToThUserEntity = tradingSimulation.SelectSharesAndUser(seller);

            SharesEntity sellerShares = tradingSimulation.ChooseShareskValue(sellerSharesToThUserEntity);

            UserAndSharesEntity customerSharesToThUserEntity = tradingSimulation.SelectStocksForUserObjectParameters(customer, sellerShares);

            int Price = tradingSimulation.RandomNumberGenerator((int)sellerShares.Price);

            int NumberOfShares = tradingSimulation.RandomNumberGenerator(sellerSharesToThUserEntity.AmountStocks);

            tradingSimulation.StockPurchaseTransaction(seller, customer, Price, NumberOfShares, sellerSharesToThUserEntity, customerSharesToThUserEntity);

            TransactionHistoryEntity transactionHistoryEntity = new TransactionHistoryEntity()
            {
                DateTimeBay = DateTime.Now,
                SellerId    = seller.Id,
                CustomerId  = customer.Id,
                AmountShare = NumberOfShares,
                Cost        = Price
            };
            TransactionService transactionService = new TransactionService(dbContext);

            transactionService.RegisterNewTransactionHistory(transactionHistoryEntity);
        }
示例#5
0
        public void Run()
        {
            Console.WriteLine("#################################");
            Console.WriteLine("Welcome to the: Trading Simulator");
            Console.WriteLine("#################################");
            Console.WriteLine(@"The database already contains some values necessary to run the application!");
            Console.WriteLine("-----------------------------------------------------------------------------");
            Console.WriteLine("press '1' to start bidding!");
            int userSelectedNumber = int.Parse(Console.ReadLine());

            Console.Clear();
            Console.WriteLine("Bidding start:");
            while (true)
            {
                if (userSelectedNumber == 1)
                {
                    Thread.Sleep(5000);
                    UserEntity seller   = tradingSimulation.ChooseARandomUser();
                    UserEntity customer = tradingSimulation.ChooseARandomUser();
                    while (seller.Equals(customer))
                    {
                        customer = tradingSimulation.ChooseARandomUser();
                    }

                    AddingSharesToThUserEntity sellerSharesToThUserEntity = tradingSimulation.SelectSharesAndUser(seller);

                    SharesEntity sellerShares = tradingSimulation.ChooseShareskValue(sellerSharesToThUserEntity);

                    AddingSharesToThUserEntity customerSharesToThUserEntity = tradingSimulation.SelectStocksForUserObjectParameters(customer, sellerShares);

                    int Price = tradingSimulation.RandomNumberGenerator((int)sellerShares.Price);

                    int NumberOfShares = tradingSimulation.RandomNumberGenerator(sellerSharesToThUserEntity.AmountStocks);

                    tradingSimulation.StockPurchaseTransaction(seller, customer, Price, NumberOfShares, sellerSharesToThUserEntity, customerSharesToThUserEntity);

                    TransactionHistoryEntity transactionHistoryEntity = new TransactionHistoryEntity()
                    {
                        DateTimeBay = DateTime.Now,
                        SellerId    = seller.Id,
                        CustomerId  = customer.Id,
                        AmountShare = NumberOfShares,
                        Cost        = Price
                    };
                    transactionService.RegisterNewTransactionHistory(transactionHistoryEntity);
                }
            }
        }