Exemple #1
0
        private static async Task SendRequestsAsync(BooksRequests booksRequests, int bookId, int memberId,
                                                    string userName, int sleepTime)
        {
            for (int i = 0; i < 150; i++)
            {
                await booksRequests.GiveBookToMemberAsync(bookId, memberId, userName);

                Thread.Sleep(sleepTime);
                await booksRequests.TakeBookFromMemberAsync(bookId, memberId, userName);
            }
        }
        static async Task Main(string[] args)
        {
            var client1 = InitializeHttpClient();
            var client2 = InitializeHttpClient();
            var client3 = InitializeHttpClient();

            var usersRequests1   = new UsersRequests(client1);
            var booksRequests1   = new BooksRequests(client1);
            var membersRequests1 = new MembersRequests(client1);

            var usersRequests2   = new UsersRequests(client2);
            var booksRequests2   = new BooksRequests(client2);
            var membersRequests2 = new MembersRequests(client2);

            var usersRequests3   = new UsersRequests(client3);
            var booksRequests3   = new BooksRequests(client3);
            var membersRequests3 = new MembersRequests(client3);

            await usersRequests1.AuthenticateAsync("admin", "111");

            var userName1 = "admin";

            await usersRequests2.AuthenticateAsync("*****@*****.**", "123");

            var userName2 = "user1";

            await usersRequests3.AuthenticateAsync("*****@*****.**", "123");

            var userName3 = "user2";

            for (int i = 0; i < 150; i++)
            {
                await booksRequests2.GiveBookToMemberAsync(2, 2, userName2);

                Thread.Sleep(1);
                await booksRequests2.TakeBookFromMemberAsync(2, 2, userName2);

                //await booksRequests1.GiveBookToMemberAsync(1, 1, userName1);
                //Thread.Sleep(500);
                //await booksRequests1.TakeBookFromMemberAsync(1, 1, userName1);
            }

            //for (int i = 0; i < 10; i++)
            //{
            //    await ConsoleWriteAsync("f**k off!", 250);
            //}
        }