Пример #1
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));
        }
Пример #2
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));
        }
Пример #3
0
        public void DeleteImageSizeShouldDeleteImageSizeWhenSuccessful()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            int       sizeOfOriginalArray = viewModel.Sizes.Count;
            ImageSize deleteCandidate     = viewModel.Sizes.Where <ImageSize>(x => x.Id == 0).First();

            // act
            viewModel.DeleteImageSize(0);

            // Assert
            Assert.AreEqual(sizeOfOriginalArray - 1, viewModel.Sizes.Count);
            Assert.IsFalse(viewModel.Sizes.Contains(deleteCandidate));
        }
Пример #4
0
        public void NameOfNewImageSizesIsIncrementedCorrectly()
        {
            // arrange
            var mockSettingsUtils = ISettingsUtilsMocks.GetStubSettingsUtils <ImageResizerSettings>();
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils.Object, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.AddRow("New size"); // Add: "New size 1"
            viewModel.AddRow("New size"); // Add: "New size 2"
            viewModel.AddRow("New size"); // Add: "New size 3"
            viewModel.DeleteImageSize(1); // Delete: "New size 2"
            viewModel.AddRow("New size"); // Add: "New Size 4"

            // Assert
            Assert.AreEqual(viewModel.Sizes[0].Name, "New size 1");
            Assert.AreEqual(viewModel.Sizes[1].Name, "New size 3");
            Assert.AreEqual(viewModel.Sizes[2].Name, "New size 4");
        }