Example #1
0
        public void TestEnoughDevices(int numPlayers,
                                      int numAndroidDevices, int numHoloLensDevices, int numDesktopDevices, bool validConfig)
        {
            var devicesByType = DeviceTestUtil.GetDevicesByType(numAndroidDevices, numHoloLensDevices, numDesktopDevices);

            DeviceTestUtil.RegisterDevices(deviceManager, devicesByType);

            var enoughDevices = deviceManager.EnoughDevicesAvailableForUserStudy(numPlayers);

            Assert.That(enoughDevices, Is.EqualTo(validConfig));
        }
Example #2
0
        public void TestDeviceConfigGeneration(int numPlayers,
                                               int numAndroidDevices, int numHoloLensDevices, int numDesktopDevices, bool validConfig)
        {
            List <List <DeviceConfig> > config;
            var devicesByType = DeviceTestUtil.GetDevicesByType(numAndroidDevices, numHoloLensDevices, numDesktopDevices);

            //settings.LogDeviceRoundConfig = true;

            deviceManager.Stub(dm => dm.EnoughDevicesAvailableForUserStudy(numPlayers)).Return(true);
            deviceManager.Stub(dm => dm.DevicesByType).Return(devicesByType);

            var success = configGenerator.TryGenerateDeviceRoundConfigs(numPlayers, out config);

            Assert.That(success, Is.EqualTo(validConfig));

            if (validConfig)
            {
                Assert.That(config.Count, Is.EqualTo(UIModeHelpers.TestUIModes.Count));
                Assert.That(config, Is.Not.Empty);
                Assert.That(config, Is.All.Not.Empty);
                Assert.That(config, Is.All.Property("Count").EqualTo(numPlayers));

                // All modes are used the right number of times
                foreach (var uiMode in UIModeHelpers.TestUIModes)
                {
                    int numUiModeUsages = CountUIModeUsagesInConfig(config, uiMode);
                    Assert.That(numUiModeUsages, Is.EqualTo(numPlayers));
                }

                // Each player uses each ui mode exactly once
                for (int p = 0; p < numPlayers; p++)
                {
                    var uiModes = new List <UIMode> (UIModeHelpers.TestUIModes);
                    foreach (var rConfig in config)
                    {
                        Assert.That(uiModes, Does.Contain(rConfig[p].UIMode));
                        uiModes.Remove(rConfig[p].UIMode);
                    }
                    Assert.That(uiModes, Is.Empty);
                }

                // Never more than the maximum number of devices per type
                foreach (var rConfig in config)
                {
                    foreach (var deviceType in devicesByType.Keys)
                    {
                        var deviceCount = rConfig.Count(dConfig => dConfig.Device.Type == deviceType);
                        Assert.That(deviceCount, Is.LessThanOrEqualTo(devicesByType[deviceType].Count));
                    }
                }

                // Each device is used at most once per round
                foreach (var rConfig in config)
                {
                    foreach (var dConfig in rConfig)
                    {
                        int numUses = rConfig.Count(dc => dc.Device.Id == dConfig.Device.Id);
                        Assert.That(numUses, Is.LessThanOrEqualTo(1));
                    }
                }
            }
        }