OLD | NEW |
| (Empty) |
1 /* | |
2 Copyright 2011 Google Inc | |
3 | |
4 Licensed under the Apache License, Version 2.0 (the "License"); | |
5 you may not use this file except in compliance with the License. | |
6 You may obtain a copy of the License at | |
7 | |
8 http://www.apache.org/licenses/LICENSE-2.0 | |
9 | |
10 Unless required by applicable law or agreed to in writing, software | |
11 distributed under the License is distributed on an "AS IS" BASIS, | |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 See the License for the specific language governing permissions and | |
14 limitations under the License. | |
15 */ | |
16 | |
17 using System.CodeDom; | |
18 | |
19 using NUnit.Framework; | |
20 | |
21 using Google.Apis.Discovery; | |
22 using Google.Apis.Requests; | |
23 using Google.Apis.Testing; | |
24 using Google.Apis.Tools.CodeGen.Decorator; | |
25 using Google.Apis.Tools.CodeGen.Decorator.ResourceDecorator.RequestDecorator; | |
26 | |
27 | |
28 namespace Google.Apis.Tools.CodeGen.Tests.Decorator.ResourceDecorator.RequestDec
orator | |
29 { | |
30 /// <summary> Tests for the ServiceRequestInheritanceDecorator. </summary> | |
31 [TestFixture] | |
32 public class ServiceRequestInheritanceDecoratorTest | |
33 { | |
34 /// <summary> Tests the constructor of this decorator. </summary> | |
35 [Test] | |
36 public void ConstructTest() | |
37 { | |
38 Assert.DoesNotThrow(() => new ServiceRequestInheritanceDecorator( | |
39 new DefaultObjectTypeProvider("Schema"))); | |
40 } | |
41 | |
42 /// <summary> Confirms that the decorator adds the ServiceRequest inheri
tance. </summary> | |
43 [Test] | |
44 public void DecorateClassTest() | |
45 { | |
46 var decorator = new ServiceRequestInheritanceDecorator( | |
47 new DefaultObjectTypeProvider("Schema")); | |
48 var resource = new MockResource(); | |
49 var method = new MockMethod() { ResponseType = "MySchema" }; | |
50 var decl = new CodeTypeDeclaration(); | |
51 var resourceDecl = new CodeTypeDeclaration(); | |
52 | |
53 // Check for ": ServiceRequest<Schema.MySchema>". | |
54 decorator.DecorateClass(resource, method, decl, resourceDecl); | |
55 Assert.AreEqual(1, decl.BaseTypes.Count); | |
56 Assert.AreEqual(typeof(ClientServiceRequest<>).FullName, decl.BaseTy
pes[0].BaseType); | |
57 Assert.AreEqual(1, decl.BaseTypes[0].TypeArguments.Count); | |
58 Assert.AreEqual("Schema.MySchema", decl.BaseTypes[0].TypeArguments[0
].BaseType); | |
59 } | |
60 } | |
61 } | |
OLD | NEW |