public void InputTemplateToAbstractConfigurationNodeJsonSerializer_Test()
        {
            var mapcol = new ControllerElementMappingProfile("Keyboard",
                                                             "TEST_CONTROLLER",
                                                             InputDriver.Keyboard,
                                                             IDeviceEnumerator.VirtualVendorID,
                                                             new XInputDeviceInstance(0).DefaultLayout);
            IDeviceInputMapping mapping = new TestInputMapping();
            var input =
                new InputTemplate <IRetroArchInput>(mapcol).Template;


            var fs   = new PhysicalFileSystem();
            var temp = Path.GetTempPath();
            var pfs  = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp));
            var dir  = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/"));

            var context = new ConfigurationTraversalContext();

            var list = context.TraverseInputTemplate(input, mapping, 0);


            var    jsonSerializer = new SimpleJsonConfigurationSerializer();
            string outputJson     = jsonSerializer.Transform(list);
            var    jtoken         = JToken.Parse(outputJson);

            Assert.True(jtoken.HasValues);
        }
Exemple #2
0
        public void InputTemplateToAbstractConfigurationNodeJsonSerializer_Test()
        {
            var testmappings = new StoneProvider().Controllers["XBOX_CONTROLLER"];
            var realmapping  =
                JsonConvert.DeserializeObject <ControllerLayout>(
                    TestUtilities.GetStringResource("InputMappings.xinput_device.json"));
            var           mapcol   = ControllerElementMappings.GetDefaultMappings(realmapping, testmappings);
            string        _mapping = TestUtilities.GetStringResource("InputMappings.DirectInput.XINPUT_DEVICE.json");
            IInputMapping mapping  = JsonConvert.DeserializeObject <InputMapping>(_mapping);
            var           input    =
                new InputTemplate <IRetroArchInput>(mapcol).Template;


            var fs   = new PhysicalFileSystem();
            var temp = Path.GetTempPath();
            var pfs  = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp));
            var dir  = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/"));

            var context = new ConfigurationTraversalContext();

            var list = context.TraverseInputTemplate(input, mapping, 0);


            var    jsonSerializer = new SimpleJsonConfigurationSerializer();
            string outputJson     = jsonSerializer.Transform(list);
            var    jtoken         = JToken.Parse(outputJson);

            Assert.True(jtoken.HasValues);
        }
        public void CollectionToAbstractConfigurationNodeJsonSerializer_Test()
        {
            var configuration =
                new ConfigurationCollection <ExampleConfigurationCollection>(new ConfigurationValueCollection());

            var fs   = new PhysicalFileSystem();
            var temp = Path.GetTempPath();
            var pfs  = fs.GetOrCreateSubFileSystem(fs.ConvertPathFromInternal(temp));
            var dir  = new FS.Directory("test", pfs, pfs.GetDirectoryEntry("/"));

            configuration.Configuration.ExampleConfiguration.FullscreenResolution = FullscreenResolution.Resolution1152X648;
            var context = new ConfigurationTraversalContext(("game", dir));

            var list = context.TraverseCollection(configuration.Configuration);
            IAbstractConfigurationNode dolphinList = list["#dolphin"];

            var    jsonSerializer = new SimpleJsonConfigurationSerializer();
            string outputJson     = jsonSerializer.Transform(dolphinList);
            var    jtoken         = JToken.Parse(outputJson);

            Assert.True(jtoken.HasValues);
        }