public async Task <ActionResult <List <AddNewQuoteCRUDResponse> > > AddAutoGeneratedQuote(int NumberOfQuotes)
        {
            List <AddNewQuoteCRUDResponse> addNewQuoteCRUDResponses = new List <AddNewQuoteCRUDResponse>();
            IStandardCRUD standardCRUD = new QuoteModelCRUD();

            QuoteCubeForPOSTCreate quoteCubeForPOST    = new QuoteCubeForPOSTCreate();
            IGenerateRandomQuote   generateRandomQuote = new GenerateRandomQuoteSimple();

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            for (int i = 0; i < NumberOfQuotes; i++)
            {
                var autogeneratedRandomQuote = generateRandomQuote.GenerateQuoteCubeRandom();
                quoteCubeForPOST.QuoteAuthor  = autogeneratedRandomQuote.QuoteAuthor;
                quoteCubeForPOST.QuoteContent = autogeneratedRandomQuote.QuoteContent;

                var crudResponse = (AddNewQuoteCRUDResponse)await standardCRUD.AddOneRow(quoteCubeForPOST, _context);

                addNewQuoteCRUDResponses.Add(crudResponse);
            }

            stopWatch.Stop();

            // Get the elapsed time as a TimeSpan value.
            _ = stopWatch.Elapsed;

            return(addNewQuoteCRUDResponses);
        }
예제 #2
0
        public void TestGenerateRandomQuoteSimple()
        {
            IGenerateRandomQuote generateRandomQuote = new GenerateRandomQuoteSimple();
            bool actual = false;

            var quoteRandom1 = generateRandomQuote.GenerateQuoteCubeRandom();
            var quoteRandom2 = generateRandomQuote.GenerateQuoteCubeRandom();

            //either the author or the quote should be different to make this quote unique.
            if (quoteRandom1.QuoteAuthor.Equals(quoteRandom2.QuoteAuthor) == false || quoteRandom1.QuoteContent.Equals(quoteRandom2.QuoteContent) == false)
            {
                actual = true;
            }
            var expected = true;

            Assert.Equal(expected, actual);
        }