Ejemplo n.º 1
0
        public async Task CanInstallPackageWithNativeDepencencies()
        {
            var options = new NugetPluginCatalogOptions()
            {
                TypeFinderOptions = new TypeFinderOptions()
                {
                    TypeFinderCriterias = new List <TypeFinderCriteria>()
                    {
                        new TypeFinderCriteria()
                        {
                            Query = (context, type) =>
                            {
                                if (string.Equals(type.Name, "SqlConnection"))
                                {
                                    return(true);
                                }

                                return(false);
                            }
                        }
                    }
                }
            };
            // Arrange
            var catalog = new NugetPackagePluginCatalog("Microsoft.Data.SqlClient", "2.1.2", options: options);

            // Act
            await catalog.Initialize();

            var plugin = catalog.Single();

            // This is the connection string part of the Weik.io docs. It provides readonly access to the Adventureworks database sample.
            // So it should be ok to have it here.
            dynamic conn = Activator.CreateInstance(plugin, "Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;");

            conn.Open();

            var cmd = conn.CreateCommand();

            cmd.CommandText = "select top 1 * from SalesLT.Customer";

            var reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                Console.WriteLine(String.Format("{0}", reader[0]));
            }

            conn.Dispose();
        }
Ejemplo n.º 2
0
            public async Task CanConfigureDefaultNamingOptions()
            {
                // Arrange
                var catalog = new NugetPackagePluginCatalog("Serilog", "2.9.0", configureFinder: configure =>
                {
                    configure.HasName("Serilog.Core.Logger");
                });

                // Act
                await catalog.Initialize();

                var plugin = catalog.Single();

                // Assert
                Assert.EndsWith("Modified", plugin.Name);
            }
Ejemplo n.º 3
0
        public async Task CanTag()
        {
            // Arrange
            var catalog = new NugetPackagePluginCatalog("Serilog", "2.9.0", configureFinder: configure =>
            {
                configure.HasName("Serilog.Core.Logger")
                .Tag("CustomTag");
            });

            // Act
            await catalog.Initialize();

            var plugin = catalog.Single();

            // Assert
            Assert.Equal("CustomTag", plugin.Tag);
        }
Ejemplo n.º 4
0
        public async Task InstallPackageWithoutDepencencies()
        {
            // Arrange
            var catalog = new NugetPackagePluginCatalog("Serilog", "2.9.0", configureFinder: configure =>
            {
                configure.HasName("Serilog.Core.Logger");
            });

            // Act
            await catalog.Initialize();

            var plugins = catalog.GetPlugins();

            // Assert
            Assert.Single(plugins);
            Assert.Equal("Serilog.Core.Logger", plugins[0].Name);
            Assert.StartsWith("2.9.0", plugins[0].Version.ToString());
            AssertAssemblyFrameWork(".NETStandard,Version=v2.0", catalog.Single().Assembly);
        }
Ejemplo n.º 5
0
        public async Task InstallPreReleasePackageWithVersionWildcard()
        {
            // Arrange
            var catalog = new NugetPackagePluginCatalog("Serilog", "2.9.1-dev*", includePrerelease: true, configureFinder: configure =>
            {
                configure.HasName("Serilog.Core.Logger");
            });

            // Act
            await catalog.Initialize();

            var plugins = catalog.GetPlugins();

            // Assert
            Assert.Single(plugins);
            Assert.Equal("Serilog.Core.Logger", plugins[0].Name);
            Assert.StartsWith("2.9.1", plugins[0].Version.ToString());
            Assert.StartsWith("2.9.1-dev", plugins[0].ProductVersion);
            AssertAssemblyFrameWork(".NETStandard,Version=v2.0", catalog.Single().Assembly);
        }
Ejemplo n.º 6
0
        public async Task CanConfigureNamingOptions()
        {
            var options = new NugetPluginCatalogOptions()
            {
                PluginNameOptions = new PluginNameOptions()
                {
                    PluginNameGenerator = (nameOptions, type) => type.FullName + "Modified"
                }
            };

            // Arrange
            var catalog = new NugetPackagePluginCatalog("Serilog", "2.9.0", configureFinder: configure =>
            {
                configure.HasName("Serilog.Core.Logger");
            }, options: options);

            // Act
            await catalog.Initialize();

            var plugin = catalog.Single();

            // Assert
            Assert.EndsWith("Modified", plugin.Name);
        }