예제 #1
0
        public void FileName_ShouldNOTUpdateValue_WhenNameIsInValid()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            string[] invalidNames =
            {
                string.Empty,
                " ",            // no name.
                "%1",           // single name value.
                "%7 (%5)",      // name max index exceeded.
                "%8 (%8)",      // name max index exceeded.
                "%5 (%3 )",     // name contains extra spaces.
                "%5  (%3)",     // name contains extra spaces.
                "%5 ( %3)",     // name contains extra spaces.
                "% 5 ( %3)",    // name contains extra spaces.
                "%5 (% 3)",     // name contains extra spaces.
                "%5 ( %3 )",    // name contains extra spaces.
            };

            // act and Assert
            foreach (string invalidName in invalidNames)
            {
                viewModel          = new ImageResizerViewModel();
                viewModel.FileName = invalidName;
                Assert.AreNotEqual(invalidName, viewModel.FileName);

                ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module);
                Assert.AreNotEqual(invalidName, settings.Properties.ImageresizerFileName.Value);
            }
        }
예제 #2
0
        public ImageResizerPage()
        {
            InitializeComponent();

            ViewModel   = new ImageResizerViewModel(ShellPage.SendDefaultIPCMessage);
            DataContext = ViewModel;
        }
        public ImageResizerPage()
        {
            InitializeComponent();

            ViewModel   = new ImageResizerViewModel();
            DataContext = ViewModel;
        }
        public ImageResizerPage()
        {
            InitializeComponent();
            var settingsUtils = new SettingsUtils();

            ViewModel   = new ImageResizerViewModel(settingsUtils, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage);
            DataContext = ViewModel;
        }
예제 #5
0
        public ImageResizerPage()
        {
            InitializeComponent();

            var settingsUtils = new SettingsUtils(new SystemIOProvider());

            ViewModel   = new ImageResizerViewModel(settingsUtils, ShellPage.SendDefaultIPCMessage);
            DataContext = ViewModel;
        }
예제 #6
0
        public void JPEGQualityLevel_ShouldSetValueToTen_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // act
            viewModel.JPEGQualityLevel = 10;

            // Assert
            viewModel = new ImageResizerViewModel();
            Assert.AreEqual(10, viewModel.JPEGQualityLevel);
        }
예제 #7
0
        public void PngInterlaceOption_ShouldSetValueToTen_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // act
            viewModel.PngInterlaceOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel();
            Assert.AreEqual(10, viewModel.PngInterlaceOption);
        }
예제 #8
0
        public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();
            int sizeOfOriginalArray         = viewModel.Sizes.Count;

            // act
            viewModel.AddRow();

            // Assert
            Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1);
        }
예제 #9
0
        public void TiffCompressOption_ShouldSetValueToTen_WhenSuccefull()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // act
            viewModel.TiffCompressOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel();
            Assert.AreEqual(10, viewModel.TiffCompressOption);
        }
예제 #10
0
        public void FileName_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();
            string expectedValue            = "%1 (%3)";

            // act
            viewModel.FileName = expectedValue;

            // Assert
            viewModel = new ImageResizerViewModel();
            Assert.AreEqual(expectedValue, viewModel.FileName);
        }
예제 #11
0
        public void Encoder_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // act
            viewModel.Encoder = 3;

            // Assert
            viewModel = new ImageResizerViewModel();
            Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder));
            Assert.AreEqual(3, viewModel.Encoder);
        }
예제 #12
0
        public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);
            int sizeOfOriginalArray = viewModel.Sizes.Count;

            // act
            viewModel.AddRow();

            // Assert
            Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1);
        }
예제 #13
0
        public void KeepDateModified_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // act
            viewModel.KeepDateModified = true;

            // Assert
            ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module);

            Assert.AreEqual(true, settings.Properties.ImageresizerKeepDateModified.Value);
        }
예제 #14
0
        public void JPEGQualityLevel_ShouldSetValueToTen_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);

            // act
            viewModel.JPEGQualityLevel = 10;

            // Assert
            viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.JPEGQualityLevel);
        }
예제 #15
0
        public void PngInterlaceOption_ShouldSetValueToTen_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);

            // act
            viewModel.PngInterlaceOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.PngInterlaceOption);
        }
예제 #16
0
        public void Encoder_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);

            // act
            viewModel.Encoder = 3;

            // Assert
            viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG);
            Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder));
            Assert.AreEqual(3, viewModel.Encoder);
        }
예제 #17
0
        public void AddRow_ShouldAddEmptyImageSize_WhenSuccessful()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils();
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SendMockIPCConfigMSG);
            int sizeOfOriginalArray = viewModel.Sizes.Count;

            // act
            viewModel.AddRow();

            // Assert
            Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray + 1);
        }
예제 #18
0
        public void KeepDateModified_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);

            // act
            viewModel.KeepDateModified = true;

            // Assert
            ImageResizerSettings settings = SettingsUtils.GetSettings <ImageResizerSettings>(Module);

            Assert.AreEqual(true, settings.Properties.ImageresizerKeepDateModified.Value);
        }
예제 #19
0
        public void FileName_ShouldUpdateValue_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);
            string expectedValue = "%1 (%3)";

            // act
            viewModel.FileName = expectedValue;

            // Assert
            viewModel = new ImageResizerViewModel(SendMockIPCConfigMSG);
            Assert.AreEqual(expectedValue, viewModel.FileName);
        }
예제 #20
0
        public void DeleteImageSize_ShouldDeleteImageSize_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();
            int       sizeOfOriginalArray   = viewModel.Sizes.Count;
            ImageSize deleteCandidate       = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            // act
            viewModel.DeleteImageSize(0);

            // Assert
            Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray - 1);
            Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
        }
예제 #21
0
        public void TiffCompressOptionShouldSetValueToTenWhenSuccessful()
        {
            // arrange
            var fileSystemMock    = new MockFileSystem();
            var mockSettingsUtils = new SettingsUtils(fileSystemMock);
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);

            // act
            viewModel.TiffCompressOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.TiffCompressOption);
        }
예제 #22
0
        public void DeleteImageSize_ShouldDeleteImageSize_WhenSuccessful()
        {
            // arrange
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(SendMockIPCConfigMSG);
            int       sizeOfOriginalArray = viewModel.Sizes.Count;
            ImageSize deleteCandidate     = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            // act
            viewModel.DeleteImageSize(0);

            // Assert
            Assert.AreEqual(viewModel.Sizes.Count, sizeOfOriginalArray - 1);
            Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
        }
예제 #23
0
        public void IsEnabled_ShouldEnableModule_WhenSuccessful()
        {
            // arrange
            ImageResizerViewModel viewModel = new ImageResizerViewModel();

            // Assert
            ShellPage.DefaultSndMSGCallback = msg =>
            {
                OutGoingGeneralSettings snd = JsonSerializer.Deserialize <OutGoingGeneralSettings>(msg);
                Assert.IsTrue(snd.GeneralSettings.Enabled.ImageResizer);
            };

            // act
            viewModel.IsEnabled = true;
        }
예제 #24
0
        public void TiffCompressOption_ShouldSetValueToTen_WhenSuccessful()
        {
            // arrange
            var mockIOProvider    = IIOProviderMocks.GetMockIOProviderForSaveLoadExists();
            var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object);
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SendMockIPCConfigMSG);

            // act
            viewModel.TiffCompressOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.TiffCompressOption);
        }
예제 #25
0
        public void JPEGQualityLevelShouldSetValueToTenWhenSuccessful()
        {
            // arrange
            var fileSystemMock    = new MockFileSystem();
            var mockSettingsUtils = new SettingsUtils(fileSystemMock);
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.JPEGQualityLevel = 10;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
            Assert.AreEqual(10, viewModel.JPEGQualityLevel);
        }