Ejemplo n.º 1
0
        public void GetMultipleMappings_Test()
        {
            var stoneProvider = new StoneProvider();

            foreach (var testmappings in stoneProvider.Controllers.Values)
            {
                var mapcol = new ControllerElementMappingProfile("Keyboard",
                                                                 "TEST_CONTROLLER",
                                                                 InputDriver.Keyboard,
                                                                 IDeviceEnumerator.VirtualVendorID,
                                                                 new XInputDeviceInstance(0).DefaultLayout);
                var mapcol2 = new ControllerElementMappingProfile("Keyboard",
                                                                  "TEST_CONTROLLER",
                                                                  InputDriver.Keyboard,
                                                                  IDeviceEnumerator.VirtualVendorID,
                                                                  new XInputDeviceInstance(0).DefaultLayout);

                var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();
                optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
                var elementStore = new ControllerElementMappingProfileStore(optionsBuilder);

                elementStore.AddMappings(mapcol, "default");
                elementStore.AddMappings(mapcol2, "default2");

                Assert.Equal(2, elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName,
                                                             IDeviceEnumerator.VirtualVendorID)
                             .Count());
                elementStore.DeleteMappings(mapcol.ProfileGuid);
                Assert.Single(elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName,
                                                           IDeviceEnumerator.VirtualVendorID));
                elementStore.DeleteMappings(mapcol.ControllerID, mapcol.DeviceName, IDeviceEnumerator.VirtualVendorID);
                Assert.Empty(elementStore.GetProfileNames(mapcol.ControllerID, InputDriver.Keyboard, mapcol.DeviceName,
                                                          IDeviceEnumerator.VirtualVendorID));
            }
        }
Ejemplo n.º 2
0
        public void DeleteMappings_Test()
        {
            var stoneProvider = new StoneProvider();

            foreach (var testmappings in stoneProvider.Controllers.Values)
            {
                var mapcol = new ControllerElementMappingProfile("Keyboard",
                                                                 "TEST_CONTROLLER",
                                                                 InputDriver.Keyboard,
                                                                 IDeviceEnumerator.VirtualVendorID,
                                                                 new XInputDeviceInstance(0).DefaultLayout);

                var optionsBuilder = new DbContextOptionsBuilder <DatabaseContext>();
                optionsBuilder.UseSqlite($"Data Source={Path.GetTempFileName()}");
                var elementStore = new ControllerElementMappingProfileStore(optionsBuilder);

                elementStore.AddMappings(mapcol, "default");

                var retStore = elementStore.GetMappings(mapcol.ProfileGuid);
                Assert.NotNull(retStore);
                elementStore.DeleteMappings(mapcol.ProfileGuid);
                var deletedRetStore = elementStore.GetMappings(mapcol.ProfileGuid);
                Assert.Null(deletedRetStore);
            }
        }