예제 #1
0
        protected override void Setup()
        {
            base.Setup();

            DbServiceMock.Setup(ds => ds.SettingsGetValue(It.Is <SettingsType>(st => st == SettingsType.DBVersion)))
            .Returns("2.0");
        }
        public void CamsDetectionWindowHeightLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.CamsDetectionWindowHeight))).Returns("546.5");
            configService.CamsDetectionWindowHeight = 1.0;
            configService.LoadSettings();

            configService.CamsDetectionWindowHeight.Should().Be(546.5);
        }
        public void CamsFovAngleLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.CamFovAngle))).Returns("75.5");
            configService.CamsFovAngle = 1;

            configService.LoadSettings();

            configService.CamsFovAngle.Should().Be(75.5);
        }
        public void MovesDetectedSleepTimeValueLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.MoveDetectedSleepTime))).Returns("0.25");
            configService.MovesDetectedSleepTimeValue = 0.1;

            configService.LoadSettings();

            configService.MovesDetectedSleepTimeValue.Should().Be(0.25);
        }
        public void MainWindowWidthLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.MainWindowWidth))).Returns("356.56");
            configService.MainWindowWidth = 1.0;

            configService.LoadSettings();

            configService.MainWindowWidth.Should().Be(356.56);
        }
        public void Cam4SetupSectorLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.Cam4SetupSector))).Returns("20/1");
            configService.Cam4SetupSector = "SomeTrash";

            configService.LoadSettings();

            configService.Cam4SetupSector.Should().Be("20/1");
        }
        public void ToCam4DistanceLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.ToCam4Distance))).Returns("35.5");
            configService.ToCam4Distance = 1.0;

            configService.LoadSettings();

            configService.ToCam4Distance.Should().Be(35.5);
        }
        public void SmoothGaussValueLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.SmoothGauss))).Returns("5");
            configService.SmoothGaussValue = 1;

            configService.LoadSettings();

            configService.SmoothGaussValue.Should().Be(5);
        }
        public void MinContourWidthValueLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.MinContourWidth))).Returns("150");
            configService.MinContourWidthValue = 1;

            configService.LoadSettings();

            configService.MinContourWidthValue.Should().Be(150);
        }
        public void Cam4YSetupValueLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.Cam4Y))).Returns("575");
            configService.Cam4YSetupValue = 1;

            configService.LoadSettings();

            configService.Cam4YSetupValue.Should().Be(575);
        }
        public void CamsResolutionHeightLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.ResolutionHeight))).Returns("1920");
            configService.CamsResolutionHeight = 1;

            configService.LoadSettings();

            configService.CamsResolutionHeight.Should().Be(1920);
        }
        public void FreeThrowsDoubleScoreWindowHeightLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.FreeThrowsDoubleScoreWindowHeight))).Returns("546.5");
            configService.FreeThrowsDoubleScoreWindowHeight = 1.0;

            configService.LoadSettings();

            configService.FreeThrowsDoubleScoreWindowHeight.Should().Be(546.5);
        }
        public void FreeThrowsSingleScoreWindowPositionTopLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.FreeThrowsSingleScoreWindowPositionTop))).Returns("546.5");
            configService.FreeThrowsSingleScoreWindowPositionTop = 1.0;

            configService.LoadSettings();

            configService.FreeThrowsSingleScoreWindowPositionTop.Should().Be(546.5);
        }
        public void ClassicScoreWindowWidthLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.ClassicScoreWindowWidth))).Returns("546.5");
            configService.ClassicScoreWindowWidth = 1.0;

            configService.LoadSettings();

            configService.ClassicScoreWindowWidth.Should().Be(546.5);
        }
        public void Cam3ThresholdSliderValueLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.Cam3ThresholdSlider))).Returns("474.56");
            configService.Cam3ThresholdSliderValue = 1.0;

            configService.LoadSettings();

            configService.Cam3ThresholdSliderValue.Should().Be(474.56);
        }
예제 #16
0
        protected override void Setup()
        {
            base.Setup();

            DbServiceMock.Setup(x => x.PlayersAllLoad()).Returns(PlayersDataTableFromDb);

            DetectionServiceMock.Setup(x => x.FindConnectedCams()).Returns("[HBV HD CAMERA]-[ID:'8&2f223cfb']");
            DetectionServiceMock.SetupAdd(m => m.OnErrorOccurred += e => { });
        }
        public void Cam4EnabledLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.Cam4CheckBox))).Returns("True");
            configService.Cam4Enabled = false;

            configService.LoadSettings();

            configService.Cam4Enabled.Should().BeTrue();
        }
        public void Cam4IdLoaded()
        {
            DbServiceMock.Setup(x => x.SettingsGetValue(It.Is <SettingsType>(s => s == SettingsType.Cam4Id))).Returns("r4rt54");
            configService.Cam4Id = "SomeTrash";

            configService.LoadSettings();

            configService.Cam4Id.Should().Be("r4rt54");
        }
        public void ErrorThrowsWhenDbVersionIsGreaterThatAppVersion()
        {
            var appVersion       = new Version(2, 0);
            var currentDbVersion = "3.1";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);

            Action act = () => { VersionChecker.CheckAndUpdate(); };

            act.Should().Throw <Exception>();
        }
        public void ErrorThrowsWhenAppVersionIsGreaterThatDbVersionAndNoConfirm()
        {
            var appVersion       = new Version(3, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(false);

            Action act = () => { VersionChecker.CheckAndUpdate(); };

            act.Should().Throw <Exception>();
        }
        public void ErrorShowsWhenDbVersionIsGreaterThatAppVersion()
        {
            var appVersion       = new Version(2, 0);
            var currentDbVersion = "3.1";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);

            InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate());

            MessageBoxServiceMock.Verify(mbs => mbs.ShowError(Resources.Resources.VersionsMismatchDbVersionGreaterErrorText,
                                                              currentDbVersion,
                                                              appVersion.ToString()),
                                         Times.Once);
        }
        public void ErrorThrowsOnMigrationError()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            DbServiceMock.Setup(ds => ds.MigrateFrom2_0to2_1()).Throws <Exception>();
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            Action act = () => { VersionChecker.CheckAndUpdate(); };

            act.Should().Throw <Exception>();
        }
        public void CopyOfOldDbDeletesWhenMigrationsSuccessfulDone()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            VersionChecker.CheckAndUpdate();

            FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName),
                                         Times.Once);
        }
        public void WarningQuestionAskedWhenAppVersionIsGreaterThatDbVersion()
        {
            var appVersion       = new Version(3, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            VersionChecker.CheckAndUpdate();

            MessageBoxServiceMock.Verify(mbs => mbs.AskWarningQuestion(Resources.Resources.VersionsMismatchWarningQuestionText,
                                                                       currentDbVersion,
                                                                       appVersion.ToString()),
                                         Times.Once);
        }
        public void ErrorShowsWhenAppVersionIsGreaterThatDbVersionAndNoConfirm()
        {
            var appVersion       = new Version(3, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(false);

            InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate());

            MessageBoxServiceMock.Verify(mbs => mbs.ShowError(Resources.Resources.VersionsMismatchErrorText,
                                                              appVersion.ToString(),
                                                              currentDbVersion),
                                         Times.Once);
        }
        public void InfoShowsWhenMigrationsSuccessfulDone()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            VersionChecker.CheckAndUpdate();

            MessageBoxServiceMock.Verify(mbs => mbs.ShowInfo(Resources.Resources.SuccessDbMigrationText,
                                                             currentDbVersion,
                                                             appVersion.ToString()),
                                         Times.Once);
        }
        public void ErrorShowsOnMigrationError()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            DbServiceMock.Setup(ds => ds.MigrateFrom2_0to2_1()).Throws <Exception>();
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate());

            MessageBoxServiceMock.Verify(mbs => mbs.ShowError(Resources.Resources.ErrorDbMigrationText,
                                                              currentDbVersion,
                                                              appVersion.ToString()),
                                         Times.Once);
        }
        public void DbRevertedOnMigrationError()
        {
            var appVersion       = new Version(2, 1);
            var currentDbVersion = "2.0";

            CreateVersionChecker(appVersion);
            DbServiceMock.Setup(ds => ds.SettingsGetValue(SettingsType.DBVersion)).Returns(currentDbVersion);
            DbServiceMock.Setup(ds => ds.MigrateFrom2_0to2_1()).Throws <Exception>();
            MessageBoxServiceMock.Setup(mbs => mbs.AskWarningQuestion(It.IsAny <string>(),
                                                                      It.IsAny <object>(),
                                                                      It.IsAny <object>())).Returns(true);

            InvokeAndSwallowException(() => VersionChecker.CheckAndUpdate());

            FileSystemServiceMock.Verify(fss => fss.CreateFileCopy(DbService.DatabaseCopyName,
                                                                   DbService.DatabaseName,
                                                                   true),
                                         Times.Once);
            FileSystemServiceMock.Verify(fss => fss.DeleteFile(DbService.DatabaseCopyName),
                                         Times.Once);
        }