public void TestTailviewerApiVersion()
        {
            IPluginPackageIndex archive = new PluginPackageIndex
            {
                TailviewerApiVersion = "4.3.2.1"
            };

            archive.TailviewerApiVersion.Should().Be(new Version(4, 3, 2, 1));
        }
        public void TestVersion()
        {
            IPluginPackageIndex archive = new PluginPackageIndex
            {
                Version = "1.2.3.4"
            };

            archive.Version.Should().Be(new Version(1, 2, 3, 4));
        }
        public void TestPluginIndexTooNew()
        {
            var index = new PluginPackageIndex
            {
                PluginArchiveVersion = PluginArchive.CurrentPluginArchiveVersion + 1
            };

            PluginGroup.FindCompatibilityErrors(index).Should().BeEquivalentTo(new object[]
            {
                new PluginError("The plugin targets a newer version of Tailviewer and must be compiled against the current version in order to be usable")
            });
        }
        public void TestRoundtripEmpty()
        {
            var archive = new PluginPackageIndex
            {
                Assemblies = { },
                ImplementedPluginInterfaces = { },
                NativeImages      = { },
                SerializableTypes = { }
            };
            var actualArchive = archive.Roundtrip();

            actualArchive.Assemblies.Should().BeEmpty();
            actualArchive.ImplementedPluginInterfaces.Should().BeEmpty();
            actualArchive.NativeImages.Should().BeEmpty();
            actualArchive.SerializableTypes.Should().BeEmpty();
        }
        public void TestPluginInterfaceUnknown()
        {
            var index = new PluginPackageIndex
            {
                PluginArchiveVersion        = PluginArchive.CurrentPluginArchiveVersion,
                ImplementedPluginInterfaces = new List <PluginInterfaceImplementation>
                {
                    new PluginInterfaceImplementation
                    {
                        InterfaceVersion  = 1,
                        InterfaceTypename = typeof(IFancyPantsInterface).FullName                         //< That interface won't be loaded by the PluginArchiverLoader because it's not part of the API project
                    }
                }
            };

            PluginGroup.FindCompatibilityErrors(index).Should().BeEquivalentTo(new object[]
            {
                new PluginError($"The plugin implements an unknown interface '{typeof(IFancyPantsInterface).FullName}' which is probably part of a newer tailviewer version. The plugin should target the current version in order to be usable!")
            });
        }
        public void TestPluginInterfaceTooNew()
        {
            var index = new PluginPackageIndex
            {
                PluginArchiveVersion        = PluginArchive.CurrentPluginArchiveVersion,
                ImplementedPluginInterfaces = new List <PluginInterfaceImplementation>
                {
                    new PluginInterfaceImplementation
                    {
                        InterfaceVersion  = 11,                        // It's a newer code, sir, and doesn't check out
                        InterfaceTypename = typeof(IDataSourceAnalyserPlugin).FullName
                    }
                }
            };

            PluginGroup.FindCompatibilityErrors(index).Should().BeEquivalentTo(new object[]
            {
                new PluginError($"The plugin implements a newer version of '{typeof(IDataSourceAnalyserPlugin).FullName}'. It must target the current version in order to be usable!")
            });
        }
        public void TestRoundtripSimple()
        {
            var archive = new PluginPackageIndex
            {
                Version = "1.2.3.4",
                TailviewerApiVersion = "0.9.8.7",
                Assemblies           = new List <AssemblyDescription>
                {
                    new AssemblyDescription
                    {
                        AssemblyFileVersion          = "A",
                        AssemblyInformationalVersion = "B",
                        AssemblyName    = "SomeAssembly",
                        AssemblyVersion = "C",
                        Dependencies    = new List <AssemblyReference>
                        {
                            new AssemblyReference
                            {
                                FullName = "AnotherAssembly"
                            }
                        },
                        EntryName = "Foobar",
                    }
                },
                ImplementedPluginInterfaces = new List <PluginInterfaceImplementation>
                {
                    new PluginInterfaceImplementation
                    {
                        ImplementationTypename = "SomeInterfaceImplementation",
                        InterfaceTypename      = "SomeInterface"
                    }
                },
                NativeImages = new List <NativeImageDescription>
                {
                    new NativeImageDescription
                    {
                        EntryName = "SomeNativeImage",
                        ImageName = "Foo.dll"
                    }
                },
                SerializableTypes = new List <SerializableTypeDescription>
                {
                    new SerializableTypeDescription
                    {
                        Name     = "SomeConfiguration",
                        FullName = "A.B.SomeConfiguration"
                    }
                }
            };
            var actualArchive = archive.Roundtrip();

            actualArchive.Version.Should().Be("1.2.3.4");
            actualArchive.TailviewerApiVersion.Should().Be("0.9.8.7");
            actualArchive.Assemblies.Should().HaveCount(1);
            actualArchive.Assemblies[0].AssemblyFileVersion.Should().Be("A");
            actualArchive.Assemblies[0].AssemblyInformationalVersion.Should().Be("B");
            actualArchive.Assemblies[0].AssemblyName.Should().Be("SomeAssembly");
            actualArchive.Assemblies[0].AssemblyVersion.Should().Be("C");
            actualArchive.Assemblies[0].Dependencies.Should().HaveCount(1);
            actualArchive.Assemblies[0].Dependencies[0].FullName.Should().Be("AnotherAssembly");
            actualArchive.Assemblies[0].EntryName.Should().Be("Foobar");

            actualArchive.ImplementedPluginInterfaces.Should().HaveCount(1);
            actualArchive.ImplementedPluginInterfaces[0].ImplementationTypename.Should()
            .Be("SomeInterfaceImplementation");
            actualArchive.ImplementedPluginInterfaces[0].InterfaceTypename.Should().Be("SomeInterface");

            actualArchive.NativeImages.Should().HaveCount(1);
            actualArchive.NativeImages[0].EntryName.Should().Be("SomeNativeImage");
            actualArchive.NativeImages[0].ImageName.Should().Be("Foo.dll");

            actualArchive.SerializableTypes.Should().HaveCount(1);
            actualArchive.SerializableTypes[0].Name.Should().Be("SomeConfiguration");
            actualArchive.SerializableTypes[0].FullName.Should().Be("A.B.SomeConfiguration");
        }