public void UnknownPlugin_ResolveServiceName_ReturnsRdp() { var dummyPlugin = new DummyPlugin(); string resolved = Resolve(0, dummyPlugin); const string MESSAGE = "If only one plugin represents required port, than its portName is resolved."; Assert.AreEqual(dummyPlugin.PortName, resolved, MESSAGE); }
static void Main(string[] args) { /* Agregar soporte para: * - COMMONCRAFT * - baseUrl: https://www.commoncraft.com/videolist * - como listar: * - bbuscar todos los links que estan dentro de un <span class="field-content"> * - como bajar video: * - obtener la pagina asociada a cada video * - Obtener la direccion del primer IFRAME que aparece en la pagina, donde se encuentra el reproductor * - De esa URL del iframe, dentro del codigo de inicializacion del player de video, bajar alguna de las URLs indicadas como "url":"https://embed....." * * * - GOGOANIME * - baseUrl: direccion original de serie (ej, https://ww3.gogoanime.io/category/dragon-ball-kai) * - como listar: * - Obtener del HTML que devuelve, el campo movie_id * - Obtener de la URL https://ww3.gogoanime.io/load-list-episode?ep_start=0&ep_end=10000&id=MOVIE_ID el listado de episodios (reemplazando MOVIE_ID por el numero obtenido) * - como bajar video: * - obtener la pagina asociada a cada video * - Obtener la direccion del primer IFRAME que aparece en la pagina, donde se encuentra el reproductor * - Obtener la segunda url del iframe * - De esa URL del iframe, obtener la URL del video (tag source, dentro de video, el que diga type="video/mp4") */ if (args.Length != 1) { Console.WriteLine("Se requiere un unico parametro 'baseUrl'"); Console.WriteLine(args.Length); return; } string url = args[0]; IPlugin plugin; if (url.Contains(url)) { plugin = new DummyPlugin(url); } else { throw new NotSupportedException("URL no soportada"); } plugin.ListarVideosDisponibles("https://www.commoncraft.com/videolist"); byte[] b = plugin.Bajar(); //BinaryWriter writer = new BinaryWriter( //writer.Write(b); }
public void GivenThatFoldersAreCorrectAndPluginAndMetadataExists_WhenLoadPluginsIsCalled_TheReturnedListContainsOnePluginContainer() { const string folderContainingPlugins = "folderContainingPlugins"; const string pluginFile = "pluginFile"; const string metadataFile = "metadataFile"; var settings = new ReflectionBasedPluginLoaderSettings("dummyPath", "dummyPluginpattern", "dummyMetadataPattern"); var directoryStub = MockRepository.GenerateStub<DirectoryBase>(); directoryStub.Stub(x => x.Exists(settings.PluginsPath)).Return(true); directoryStub.Stub(x => x.EnumerateDirectories(settings.PluginsPath)) .Return(new[] { folderContainingPlugins }); directoryStub.Stub( x => x.EnumerateFiles(folderContainingPlugins, settings.PluginFileSearchPattern, SearchOption.TopDirectoryOnly)) .Return(new[] { pluginFile }); directoryStub.Stub( x => x.EnumerateFiles(folderContainingPlugins, settings.PluginMetadataSearchPattern, SearchOption.TopDirectoryOnly)) .Return(new[] { metadataFile }); var plugin = new DummyPlugin(); var metadata = new YarpPluginMetadata("id", "name", "author", "description", "version", "category", "website"); var assemblyLoaderStub = MockRepository.GenerateStub<IAssemblyLoader>(); assemblyLoaderStub.Stub(x => x.LoadFile(pluginFile)).Return(null); var activatorStub = MockRepository.GenerateStub<IYarpActivator>(); activatorStub.Stub(x => x.CreateInstance<IYarpPlugin>(null)).IgnoreArguments().Return(plugin); var serializerStub = MockRepository.GenerateStub<IYarpSerializer>(); serializerStub.Stub(x => x.Deserialize<YarpPluginMetadata>("")).IgnoreArguments().Return(metadata); var fileStub = MockRepository.GenerateStub<FileBase>(); fileStub.Stub(x => x.ReadAllText("")).IgnoreArguments().Return("someFileData"); var sut = CreateSut(settings, activator: activatorStub, loader: assemblyLoaderStub, directory: directoryStub, file:fileStub, serializer:serializerStub); var loadedPlugins = sut.LoadPlugins().ToList(); var loadedMetadata = loadedPlugins[0].Metadata; var loadedPlugin = loadedPlugins[0].Plugin; loadedPlugin.Activate(); loadedPlugin.Deactivate(); Assert.AreEqual(1, loadedPlugins.Count); Assert.IsTrue(ArePluginMetadatasEqual(metadata, loadedMetadata)); Assert.IsTrue(plugin.HasBeenActivated); Assert.IsTrue(plugin.HasBeenDeactivated); }
public void Can_get_plugin_info() { var plugin = new DummyPlugin(); PluginInspector pluginInspector; plugin.Configure(null, out pluginInspector); var info = new PluginInspectorExtrator(new List <PluginInspector> { pluginInspector }).ToString(); Assert.That(info, Is.StringContaining("DummyPlugin")); Assert.That(info, Is.StringContaining("Mensagem teste")); }
public void TestBuildWithDummyPlugin() { var dummyPlugin = new DummyPlugin(); AWSXRayRecorder recorder = new AWSXRayRecorderBuilder().WithPlugin(dummyPlugin).Build(); recorder.BeginSegment("test", TraceId); var segment = (Segment)TraceContext.GetEntity(); recorder.EndSegment(); Assert.AreEqual("Origin", segment.Origin); var dict = segment.Aws[dummyPlugin.ServiceName] as Dictionary <string, object>; Assert.AreEqual("value1", dict["key1"]); }
public void ResolvePlugin_WhenWellFormed_ReturnsPluginObject() { var registry = new Registry(); var handlerFactory = MockRepository.GenerateMock<IHandlerFactory>(); var plugin = registry.RegisterPlugin(new PluginRegistration("pluginId", new TypeName(typeof(DummyPlugin)), new DirectoryInfo(@"C:\")) { PluginHandlerFactory = handlerFactory, PluginProperties = { { "Name", "Value" } } }); var handler = MockRepository.GenerateMock<IHandler>(); var pluginInstance = new DummyPlugin(); handlerFactory.Expect(x => x.CreateHandler(null, null, null, null)) .Constraints(Is.NotNull(), Is.Equal(typeof(IPlugin)), Is.Equal(typeof(DummyPlugin)), Is.Equal(new PropertySet() { { "Name", "Value" } })) .Return(handler); handler.Expect(x => x.Activate()).Return(pluginInstance); var result = (DummyPlugin) plugin.ResolvePlugin(); handlerFactory.VerifyAllExpectations(); handler.VerifyAllExpectations(); Assert.AreSame(pluginInstance, result); }