9 changed files with 105 additions and 4 deletions
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
// 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; |
||||
|
||||
namespace ICSharpCode.TextTemplating |
||||
{ |
||||
public class TextTemplatingServiceProvider : IServiceProvider |
||||
{ |
||||
public object GetService(Type serviceType) |
||||
{ |
||||
return serviceType.Assembly.CreateInstance(serviceType.FullName); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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.Collections.Generic; |
||||
|
||||
namespace TextTemplating.Tests.Helpers |
||||
{ |
||||
public class FakeServiceProvider : IServiceProvider |
||||
{ |
||||
public Dictionary<Type, object> Services = new Dictionary<Type, object>(); |
||||
|
||||
public void AddService(Type serviceType, object service) |
||||
{ |
||||
Services.Add(serviceType, service); |
||||
} |
||||
|
||||
public object GetService(Type serviceType) |
||||
{ |
||||
object service = null; |
||||
Services.TryGetValue(serviceType, out service); |
||||
return service; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// 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 ICSharpCode.TextTemplating; |
||||
using NUnit.Framework; |
||||
using TextTemplating.Tests.Helpers; |
||||
|
||||
namespace TextTemplating.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class TextTemplatingServiceProviderTests |
||||
{ |
||||
TextTemplatingServiceProvider serviceProvider; |
||||
|
||||
void CreateServiceProvider() |
||||
{ |
||||
serviceProvider = new TextTemplatingServiceProvider(); |
||||
} |
||||
|
||||
[Test] |
||||
public void GetService_TypeOfFakeServiceProvider_ReturnsNewFakeServiceProvider() |
||||
{ |
||||
CreateServiceProvider(); |
||||
FakeServiceProvider service = serviceProvider.GetService(typeof(FakeServiceProvider)) as FakeServiceProvider; |
||||
|
||||
Assert.IsNotNull(service); |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue