This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 771
/
ServiceReferenceProxyGeneratorTests.cs
64 lines (53 loc) · 2.34 KB
/
ServiceReferenceProxyGeneratorTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.CodeDom;
using System.ServiceModel.Description;
using ICSharpCode.SharpDevelop.Gui.Dialogs.ReferenceDialog.ServiceReference;
using NUnit.Framework;
using Rhino.Mocks;
namespace ICSharpCode.SharpDevelop.Tests.ServiceReferences
{
[TestFixture]
public class ServiceReferenceProxyGeneratorTests
{
ServiceReferenceProxyGenerator proxyGenerator;
IProjectWithServiceReferences fakeProject;
IServiceReferenceCodeDomBuilder fakeCodeDomBuilder;
ICodeDomProvider fakeCodeDomProvider;
MetadataSet metadata;
void CreateProxyGenerator()
{
metadata = new MetadataSet();
fakeCodeDomBuilder = MockRepository.GenerateStub<IServiceReferenceCodeDomBuilder>();
fakeProject = MockRepository.GenerateStub<IProjectWithServiceReferences>();
fakeCodeDomProvider = MockRepository.GenerateStub<ICodeDomProvider>();
proxyGenerator = new ServiceReferenceProxyGenerator(fakeCodeDomProvider, fakeCodeDomBuilder);
}
CodeCompileUnit CreateCompileUnitToReturnFromCodeDomBuilder(MetadataSet metadata)
{
var compileUnit = new CodeCompileUnit();
fakeCodeDomBuilder.Stub(c => c.GenerateCompileUnit(metadata)).Return(compileUnit);
return compileUnit;
}
[Test]
public void GenerateProxyFile_ProxyToBeGeneratedForMetadata_CodeGeneratedFromCodeDomForProxyFileInProjectSubFolder()
{
CreateProxyGenerator();
CodeCompileUnit compileUnit = CreateCompileUnitToReturnFromCodeDomBuilder(metadata);
proxyGenerator.ServiceReferenceNamespace = "Test";
string expectedProxyFileName = @"d:\projects\MyProject\Service References\Test\Service1\Reference.cs";
proxyGenerator.GenerateProxyFile(metadata, expectedProxyFileName);
fakeCodeDomProvider.AssertWasCalled(p => p.GenerateCodeFromCompileUnit(compileUnit, expectedProxyFileName));
}
[Test]
public void GenerateProxyFile_ProxyToBeGeneratedForMetadata_NamespaceUsedWhenGeneratingCodeDom()
{
CreateProxyGenerator();
CreateCompileUnitToReturnFromCodeDomBuilder(metadata);
proxyGenerator.ServiceReferenceNamespace = "Test";
proxyGenerator.GenerateProxyFile(metadata, "Reference.cs");
Assert.AreEqual("Test", fakeCodeDomBuilder.Namespace);
}
}
}