Esempio n. 1
0
        public void TestSuccess() {
            var protocols = new ProtocolController();

            protocols.Dispose();

            Assert.IsNull(protocols.Protocols);
        }
        public void TestSuccess() {
            var protocols = new ProtocolController();

            ICommandResult result = protocols.Tunnel(CommandBuilder.ProtocolsFetchSupportedProtocols().SetOrigin(CommandOrigin.Local));

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
        public void TestInsufficientPermissions() {
            var protocols = new ProtocolController();

            ICommandResult result = protocols.Tunnel(CommandBuilder.ProtocolsCheckSupportedProtocol("Myrcon", CommonProtocolType.DiceBattlefield4).SetOrigin(CommandOrigin.Remote).SetAuthentication(new CommandAuthenticationModel() {
                Username = "******"
            }));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.InsufficientPermissions, result.CommandResultType);
        }
        public void TestAllProtocolAssembliesFilesFoundInPackageRoot() {
            var dll = new FileInfo(Path.Combine(this.TestGetProtocolAssembliesDirectory.FullName, "Something.Protocols.Something", "Something.Protocols.Something.dll"));
            if (dll.Directory != null) dll.Directory.Create();

            File.WriteAllText(dll.FullName, @"binary");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestGetProtocolAssembliesDirectory
            };

            var files = protocols.GetProtocolAssemblies();

            Assert.AreEqual(1, files.Count);
            Assert.AreEqual(dll.FullName, files.First().FullName);
        }
Esempio n. 5
0
        public void TestPackageDirectoryReturnedSecondDepth() {
            DirectoryInfo package = new DirectoryInfo(Path.Combine(this.TestTestGetProtocolPackages.FullName, "Something.Protocols.Something"));

            var dll = new FileInfo(Path.Combine(package.FullName, "SubDirectory", "Something.Protocols.Something.dll"));
            if (dll.Directory != null) dll.Directory.Create();

            File.WriteAllText(dll.FullName, @"binary");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestTestGetProtocolPackages
            };

            var packages = protocols.GetProtocolPackages(new List<FileInfo>() { dll });

            Assert.AreEqual(1, packages.Count);
            Assert.AreEqual(package.FullName, packages.First().FullName);
        }
        public void TestLoadedWithSingleVersionOfPackage() {
            DirectoryInfo package = new DirectoryInfo(Path.Combine(this.TestLoadProtocolsMetadataDirectory.FullName, "Something.Protocols.Something"));

            var dll = new FileInfo(Path.Combine(package.FullName, "lib", "Something.Protocols.Something.dll"));
            if (dll.Directory != null) dll.Directory.Create();
            File.WriteAllText(dll.FullName, @"binary");

            var json = new FileInfo(Path.Combine(package.FullName, "Content", "Something.Protocols.Something.json"));
            if (json.Directory != null) json.Directory.Create();
            File.WriteAllText(json.FullName, @"{ }");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestLoadProtocolsMetadataDirectory
            };

            protocols.LoadProtocolsMetadata();

            Assert.AreEqual(1, protocols.Protocols.Count);
        }
        public void TestProtocolTypesReturned() {
            var item = new ProtocolType() {
                Name = "Battlefield 4",
                Provider = "Myrcon",
                Type = "DiceBattlefield4"
            };
            
            var protocols = new ProtocolController {
                Protocols = new List<IProtocolAssemblyMetadata>() {
                    new ProtocolAssemblyMetadata() {
                        ProtocolTypes = new List<IProtocolType>() {
                            item
                        }
                    }
                }
            };

            ICommandResult result = protocols.Tunnel(CommandBuilder.ProtocolsFetchSupportedProtocols().SetOrigin(CommandOrigin.Local));

            Assert.AreEqual(item, result.Now.ProtocolTypes.First());
        }
        public void TestSuccess() {
            var item = new ProtocolType() {
                Name = "Battlefield 4",
                Provider = "Myrcon",
                Type = CommonProtocolType.DiceBattlefield4
            };

            var protocols = new ProtocolController {
                Protocols = new List<IProtocolAssemblyMetadata>() {
                    new ProtocolAssemblyMetadata() {
                        ProtocolTypes = new List<IProtocolType>() {
                            item
                        }
                    }
                }
            };

            ICommandResult result = protocols.Tunnel(CommandBuilder.ProtocolsCheckSupportedProtocol("Myrcon", CommonProtocolType.DiceBattlefield4).SetOrigin(CommandOrigin.Local));

            Assert.IsTrue(result.Success);
            Assert.AreEqual(CommandResultType.Success, result.CommandResultType);
        }
        public void TestFailureDoesNotExist() {
            var protocols = new ProtocolController();

            ICommandResult result = protocols.Tunnel(CommandBuilder.ProtocolsCheckSupportedProtocol("Myrcon", CommonProtocolType.DiceBattlefield4).SetOrigin(CommandOrigin.Local));

            Assert.IsFalse(result.Success);
            Assert.AreEqual(CommandResultType.DoesNotExists, result.CommandResultType);
        }
Esempio n. 10
0
        public void TestSingleProtocolLoadedWithMultipleVersionsOfPackage() {
            DirectoryInfo newest = new DirectoryInfo(Path.Combine(this.TestLoadProtocolsMetadataDirectory.FullName, "Something.Protocols.Something.2.0.0"));
            DirectoryInfo oldest = new DirectoryInfo(Path.Combine(this.TestLoadProtocolsMetadataDirectory.FullName, "Something.Protocols.Something.1.0.0"));

            var newestdll = new FileInfo(Path.Combine(newest.FullName, "lib", "Something.Protocols.Something.dll"));
            if (newestdll.Directory != null) newestdll.Directory.Create();
            File.WriteAllText(newestdll.FullName, @"binary");

            var newestjson = new FileInfo(Path.Combine(newest.FullName, "Content", "Something.Protocols.Something.json"));
            if (newestjson.Directory != null) newestjson.Directory.Create();
            File.WriteAllText(newestjson.FullName, @"{ }");

            var oldestdll = new FileInfo(Path.Combine(oldest.FullName, "lib", "Something.Protocols.Something.dll"));
            if (oldestdll.Directory != null) oldestdll.Directory.Create();
            File.WriteAllText(oldestdll.FullName, @"binary");

            var oldestjson = new FileInfo(Path.Combine(oldest.FullName, "Content", "Something.Protocols.Something.json"));
            if (oldestjson.Directory != null) oldestjson.Directory.Create();
            File.WriteAllText(oldestjson.FullName, @"{ }");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestLoadProtocolsMetadataDirectory
            };

            protocols.LoadProtocolsMetadata();

            Assert.AreEqual(1, protocols.Protocols.Count);
        }
Esempio n. 11
0
        public void TestProtocolVariablesLoaded() {
            DirectoryInfo package = new DirectoryInfo(Path.Combine(this.TestLoadProtocolsMetadataDirectory.FullName, "Something.Protocols.Something"));

            var dll = new FileInfo(Path.Combine(package.FullName, "lib", "Something.Protocols.Something.dll"));
            if (dll.Directory != null) dll.Directory.Create();
            File.WriteAllText(dll.FullName, @"binary");

            var json = new FileInfo(Path.Combine(package.FullName, "Content", "Something.Protocols.Something.json"));
            if (json.Directory != null) json.Directory.Create();
            File.WriteAllText(json.FullName, @"{ ""ProtocolTypes"": [ { ""Provider"": ""Myrcon"",""Name"": ""Battlefield 4"",""Type"": ""DiceBattlefield4"" } ] }");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestLoadProtocolsMetadataDirectory
            };

            protocols.LoadProtocolsMetadata();

            Assert.AreEqual("DiceBattlefield4", protocols.Protocols.First().ProtocolTypes.First().Type);
        }
Esempio n. 12
0
        public void TestLatestPackagePathReturned() {
            DirectoryInfo latest = new DirectoryInfo(Path.Combine(this.TestTestGetProtocolPackages.FullName, "Something.Protocols.Something.2.0.0"));
            DirectoryInfo oldest = new DirectoryInfo(Path.Combine(this.TestTestGetProtocolPackages.FullName, "Something.Protocols.Something.1.0.0"));

            var latestDll = new FileInfo(Path.Combine(latest.FullName, "SubDirectory", "Something.Protocols.Something.dll"));
            if (latestDll.Directory != null) latestDll.Directory.Create();
            File.WriteAllText(latestDll.FullName, @"binary");

            var oldestDll = new FileInfo(Path.Combine(oldest.FullName, "SubDirectory", "Something.Protocols.Something.dll"));
            if (oldestDll.Directory != null) oldestDll.Directory.Create();
            File.WriteAllText(oldestDll.FullName, @"binary");

            var protocols = new ProtocolController() {
                PackagesDirectory = this.TestTestGetProtocolPackages
            };

            var packages = protocols.GetProtocolPackages(new List<FileInfo>() { latestDll, oldestDll });

            Assert.AreEqual(1, packages.Count);
            Assert.AreEqual(latest.FullName, packages.First().FullName);
        }