Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2315)

Side by Side Diff: Src/GoogleApis.Tools.CodeGen.Tests/Decorator/ResourceDecorator/StandardServiceFieldResourceDecoratorTest.cs

Issue 12020043: Issue 325 - Remove discovery and codegen (Closed) Base URL: https://google-api-dotnet-client.googlecode.com/hg/
Patch Set: Sir miceli comment Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 Copyright 2010 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 using System.CodeDom;
17 using NUnit.Framework;
18
19 using Google.Apis.Discovery;
20 using Google.Apis.Services;
21 using Google.Apis.Tools.CodeGen.Decorator.ResourceDecorator;
22 using Google.Apis.Tools.CodeGen.Generator;
23
24
25 namespace Google.Apis.Tools.CodeGen.Tests.Decorator.ResourceDecorator
26 {
27 /// <summary>
28 /// Tests for the StandardServiceFieldResourceDecorator
29 /// </summary>
30 [TestFixture]
31 public class StandardServiceFieldResourceDecoratorTest : BaseResourceDecorat orTest
32 {
33 /// <summary>
34 /// Tests the decorator
35 /// </summary>
36 [Test]
37 public void DecorateClassTest()
38 {
39 var decorator = new StandardServiceFieldResourceDecorator();
40 CodeNamespace nameSpace = new CodeNamespace("Google.Apis.Tools.CodeG en.Tests");
41 nameSpace.Types.Add(new CodeTypeDeclaration("TestServiceClass"));
42
43 CodeTypeDeclaration codeType = CreateDecoratedResourceClass(decorato r);
44 nameSpace.Types.Add(codeType);
45
46 Assert.AreEqual(2, codeType.Members.Count);
47 Assert.IsInstanceOf(typeof(CodeMemberField), codeType.Members[0]);
48 var codeField = (CodeMemberField)codeType.Members[0];
49 Assert.AreEqual(ResourceBaseGenerator.ServiceFieldName, codeField.Na me);
50 var ccu = new CodeCompileUnit();
51 ccu.Namespaces.Add(nameSpace);
52
53 CheckCompile(ccu, false, "Failed To Compile StandardServiceFieldReso urceDecorator");
54 }
55
56 /// <summary>
57 /// Tests the ability to create the service field
58 /// </summary>
59 [Test]
60 public void TestCreateServiceField()
61 {
62 string serviceName = typeof(IClientService).FullName;
63 var decorator = new StandardServiceFieldResourceDecorator();
64 CodeMemberField codeField = decorator.CreateServiceField(serviceName );
65
66 Assert.IsNotNull(codeField);
67 Assert.AreEqual(ResourceBaseGenerator.ServiceFieldName, codeField.Na me);
68 Assert.AreEqual(serviceName, codeField.Type.BaseType);
69 Assert.IsNull(codeField.InitExpression);
70 }
71 }
72 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b