| | 1 | | using System.Net.Http; |
| | 2 | | using System.Threading; |
| | 3 | | using System.Threading.Tasks; |
| | 4 | | using Microsoft.VisualStudio.TestTools.UnitTesting; |
| | 5 | |
|
| | 6 | | namespace Test |
| | 7 | | { |
| | 8 | | [TestClass] |
| | 9 | | public class Program |
| | 10 | | { |
| | 11 | | static void Main(string[] args) |
| | 12 | | { |
| | 13 | | new TestClass().SampleFunction(); |
| | 14 | |
|
| | 15 | | new TestClass2("Test").ExecutedMethod(); |
| | 16 | | new TestClass2("Test").SampleFunction("Munich"); |
| | 17 | |
|
| | 18 | | new PartialClass().ExecutedMethod_1(); |
| | 19 | | new PartialClass().ExecutedMethod_2(); |
| | 20 | | new PartialClass().SomeProperty = -10; |
| | 21 | |
|
| 2 | 22 | | new PartialClassWithAutoProperties().Property1 = "Test"; |
| | 23 | | new PartialClassWithAutoProperties().Property2 = "Test"; |
| | 24 | |
|
| | 25 | | new SomeClass().Property1 = "Test"; |
| | 26 | |
|
| | 27 | | new ClassWithExcludes().IncludedMethod(); |
| | 28 | | new ClassWithExcludes().ExcludedMethod(); |
| | 29 | |
|
| | 30 | | new GenericClass<SomeModel, IState>().Process(null); |
| | 31 | | new GenericClass<SomeModel, IState>().PostProcess(null); |
| | 32 | |
|
| | 33 | | new CodeContract_Target().Calculate(-1); |
| | 34 | |
|
| | 35 | | new AbstractClass_SampleImpl1(); |
| | 36 | | new AbstractClass_SampleImpl2(); |
| | 37 | |
|
| | 38 | | CallAsyncMethod(); |
| | 39 | |
|
| | 40 | | try |
| | 41 | | { |
| | 42 | | new CodeContract_Target().Calculate(0); |
| | 43 | | } |
| | 44 | | catch (System.ArgumentException) |
| | 45 | | { |
| | 46 | | } |
| | 47 | | } |
| | 48 | |
|
| | 49 | | [TestMethod] |
| 2 | 50 | | public void CSharp_ExecuteTest1() |
| | 51 | | { |
| | 52 | | Main(null); |
| | 53 | | } |
| | 54 | |
|
| | 55 | | [TestMethod] |
| | 56 | | public void CSharp_ExecuteTest2() |
| | 57 | | { |
| | 58 | | Main(null); |
| | 59 | | } |
| | 60 | |
|
| | 61 | | private static async void CallAsyncMethod() |
| 1 | 62 | | { |
| 1 | 63 | | var expected = new HttpResponseMessage(); |
| 1 | 64 | | var handler = new AsyncClass() { InnerHandler = new EchoHandler(expected) }; |
| 1 | 65 | | var invoker = new HttpMessageInvoker(handler, false); |
| 1 | 66 | | var actual = await invoker.SendAsync(new HttpRequestMessage(), new CancellationToken()); |
| 1 | 67 | | } |
| | 68 | |
|
| | 69 | | private class EchoHandler : DelegatingHandler |
| | 70 | | { |
| | 71 | | private HttpResponseMessage _response; |
| | 72 | |
|
| 1 | 73 | | public EchoHandler(HttpResponseMessage response) |
| 1 | 74 | | { |
| 1 | 75 | | this._response = response; |
| 1 | 76 | | } |
| | 77 | |
|
| | 78 | | protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancell |
| 1 | 79 | | { |
| 1 | 80 | | return Task.FromResult(this._response); |
| 1 | 81 | | } |
| | 82 | | } |
| | 83 | | } |
| | 84 | | } |