コード例 #1
0
        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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }