public void Should_Load_Custom_UserService() { // Arrange ApplicationSettings applicationSettings = new ApplicationSettings(); applicationSettings.UserServiceType = "Roadkill.Tests.UserServiceStub"; DependencyManager iocSetup = new DependencyManager(applicationSettings); // Put the UserServiceStub in a new assembly so we can test it's loaded string tempFilename = Path.GetFileName(Path.GetTempFileName()) + ".dll"; string thisAssembly = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Roadkill.Tests.dll"); string pluginSourceDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins", "UserService"); string destPlugin = Path.Combine(pluginSourceDir, tempFilename); if (!Directory.Exists(pluginSourceDir)) { Directory.CreateDirectory(pluginSourceDir); } File.Copy(thisAssembly, destPlugin, true); // Act iocSetup.Configure(); // Assert UserServiceBase userManager = ObjectFactory.GetInstance <UserServiceBase>(); Assert.That(userManager.GetType().FullName, Is.EqualTo("Roadkill.Tests.UserServiceStub")); }
public void should_load_custom_userservice_using_assemblyqualifiedname() { // Arrange ApplicationSettings settings = new ApplicationSettings(); settings.ConnectionString = "none empty connection string"; settings.UserServiceType = typeof(Roadkill.Plugins.TestUserService).AssemblyQualifiedName; Console.WriteLine(settings.UserServiceType); settings.PluginsBinPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"); // Act var registry = new RoadkillRegistry(new ConfigReaderWriterStub() { ApplicationSettings = settings }); var container = new Container(registry); // Act UserServiceBase userService = container.GetInstance <UserServiceBase>(); Assert.That(userService, Is.Not.Null); Assert.That(userService.GetType().AssemblyQualifiedName, Is.EqualTo(settings.UserServiceType)); }