Updated for VS2015
Showing
2 changed files
with
26 additions
and
11 deletions
... | @@ -59,6 +59,24 @@ namespace PerformanceTestProject | ... | @@ -59,6 +59,24 @@ namespace PerformanceTestProject |
59 | // | 59 | // |
60 | #endregion | 60 | #endregion |
61 | 61 | ||
62 | // Use TestInitialize to run code before running each test | ||
63 | private bool inLoadTest = false; | ||
64 | private bool dontKnow = true; | ||
65 | [TestInitialize()] | ||
66 | public void CheckTestContextType() | ||
67 | { | ||
68 | if (dontKnow) | ||
69 | { | ||
70 | // Check if the TestContext type is the one that a loadtest provides | ||
71 | if (TestContext.GetType().ToString().Equals("Microsoft.VisualStudio.TestTools.TestTypes.Unit.UnitTestAdapterContext")) | ||
72 | inLoadTest = true; | ||
73 | else | ||
74 | inLoadTest = false; | ||
75 | dontKnow = false; | ||
76 | TestContext.WriteLine("We have a loadtest TestContext: " + inLoadTest); | ||
77 | } | ||
78 | } | ||
79 | |||
62 | [TestMethod] | 80 | [TestMethod] |
63 | public void AF01_Validate() | 81 | public void AF01_Validate() |
64 | { | 82 | { |
... | @@ -73,11 +91,11 @@ namespace PerformanceTestProject | ... | @@ -73,11 +91,11 @@ namespace PerformanceTestProject |
73 | // Logga vad vi gör... | 91 | // Logga vad vi gör... |
74 | TestContext.WriteLine("Anropar Validate med indata: " + "christian@gerdes.se"); | 92 | TestContext.WriteLine("Anropar Validate med indata: " + "christian@gerdes.se"); |
75 | // Skapa timer | 93 | // Skapa timer |
76 | TestContext.BeginTimer("01_ValidateCall"); | 94 | if (inLoadTest) TestContext.BeginTimer("01_ValidateCall"); |
77 | // Utför anrop mot tjänsten | 95 | // Utför anrop mot tjänsten |
78 | bool response = myClient.ValidateAddress("christian@gerdes.se"); | 96 | bool response = myClient.ValidateAddress("christian@gerdes.se"); |
79 | // Stoppa Timer | 97 | // Stoppa Timer |
80 | TestContext.EndTimer("01_ValidateCall"); | 98 | if (inLoadTest) TestContext.EndTimer("01_ValidateCall"); |
81 | 99 | ||
82 | // Verifiera svaret | 100 | // Verifiera svaret |
83 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); | 101 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); |
... | @@ -109,11 +127,11 @@ namespace PerformanceTestProject | ... | @@ -109,11 +127,11 @@ namespace PerformanceTestProject |
109 | // Logga vad vi gör... | 127 | // Logga vad vi gör... |
110 | TestContext.WriteLine("Anropar CheckIfFull"); | 128 | TestContext.WriteLine("Anropar CheckIfFull"); |
111 | // Skapa timer | 129 | // Skapa timer |
112 | TestContext.BeginTimer("01_CheckIfFull"); | 130 | if (inLoadTest) TestContext.BeginTimer("01_CheckIfFull"); |
113 | // Utför anrop mot tjänsten | 131 | // Utför anrop mot tjänsten |
114 | bool response = myClient.checkIfFull(); | 132 | bool response = myClient.checkIfFull(); |
115 | // Stoppa Timer | 133 | // Stoppa Timer |
116 | TestContext.EndTimer("01_CheckIfFull"); | 134 | if (inLoadTest) TestContext.EndTimer("01_CheckIfFull"); |
117 | 135 | ||
118 | // Verifiera svaret | 136 | // Verifiera svaret |
119 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); | 137 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); |
... | @@ -145,11 +163,11 @@ namespace PerformanceTestProject | ... | @@ -145,11 +163,11 @@ namespace PerformanceTestProject |
145 | // Logga vad vi gör... | 163 | // Logga vad vi gör... |
146 | TestContext.WriteLine("Anropar CheckIfFull"); | 164 | TestContext.WriteLine("Anropar CheckIfFull"); |
147 | // Skapa timer | 165 | // Skapa timer |
148 | TestContext.BeginTimer("03_Register"); | 166 | if (inLoadTest) TestContext.BeginTimer("03_Register"); |
149 | // Utför anrop mot tjänsten | 167 | // Utför anrop mot tjänsten |
150 | int response = myClient.RegisterAdress("christian.gerdes@lightsinline.se"); | 168 | int response = myClient.RegisterAdress("christian.gerdes@lightsinline.se"); |
151 | // Stoppa Timer | 169 | // Stoppa Timer |
152 | TestContext.EndTimer("03_Register"); | 170 | if (inLoadTest) TestContext.EndTimer("03_Register"); |
153 | 171 | ||
154 | // Verifiera svaret | 172 | // Verifiera svaret |
155 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); | 173 | TestContext.WriteLine("Svaret som mottogs är: " + response.ToString()); | ... | ... |
1 | | 1 | |
2 | Microsoft Visual Studio Solution File, Format Version 12.00 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 |
3 | # Visual Studio 2013 | 3 | # Visual Studio 14 |
4 | VisualStudioVersion = 12.0.21005.1 | 4 | VisualStudioVersion = 14.0.24720.0 |
5 | MinimumVisualStudioVersion = 10.0.40219.1 | 5 | MinimumVisualStudioVersion = 10.0.40219.1 |
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8784D56B-3A97-4F31-9E2F-36A6099C8D8E}" | 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8784D56B-3A97-4F31-9E2F-36A6099C8D8E}" |
7 | ProjectSection(SolutionItems) = preProject | 7 | ProjectSection(SolutionItems) = preProject |
8 | Local.testsettings = Local.testsettings | 8 | Local.testsettings = Local.testsettings |
9 | Taurus.testsettings = Taurus.testsettings | ||
10 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings | ||
11 | WCFPerformanceServiceDemo.vsmdi = WCFPerformanceServiceDemo.vsmdi | ||
12 | EndProjectSection | 9 | EndProjectSection |
13 | EndProject | 10 | EndProject |
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerformanceService", "PerformanceService\PerformanceService.csproj", "{298113F4-7126-4E1A-ADD1-F6C5327370E8}" | 11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PerformanceService", "PerformanceService\PerformanceService.csproj", "{298113F4-7126-4E1A-ADD1-F6C5327370E8}" | ... | ... |
-
Please register or sign in to post a comment