Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- [TestClass]
- public class UnitTestPerformance
- {
- [TestMethod]
- [Timeout(5000)]
- public void TestSearchPerformance()
- {
- int addsCount = 10000;
- int searchCount = 50000;
- // Prepare the input commands
- StringBuilder input = new StringBuilder();
- for (int i = 0; i < addsCount; i++)
- {
- input.AppendLine("Add application: app; a; 12345; http://oldurl");
- }
- for (int i = 0; i < searchCount; i++)
- {
- input.AppendLine("Find: app; 100");
- }
- input.AppendLine("End");
- // Prepare the expected result
- StringBuilder expectedOutput = new StringBuilder();
- for (int i = 0; i < addsCount; i++)
- {
- expectedOutput.AppendLine("Application added");
- }
- for (int i = 0; i < searchCount * 100; i++)
- {
- expectedOutput.AppendLine("Application: app; a; 12345; http://oldurl");
- }
- // Redirect the console input / output and invoke the Main() method
- Console.SetIn(new StringReader(input.ToString()));
- StringWriter consoleOutput = new StringWriter();
- Console.SetOut(consoleOutput);
- Problem04_Free_Content.Program.Main();
- // Assert that the program execution result is correct
- string expected = expectedOutput.ToString();
- string actual = consoleOutput.ToString();
- Assert.AreEqual(expected, actual);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement