コード例 #1
0
        public void InitializeConfigFile_InstalledFileExists_UserFileExists_ReturnTrue()
        {
            string installedFilePath = "installedFilePath";
            string userFilePath      = "userFilePath";
            IFileSystemOperation stubFileSystemOperator = MockRepository.GenerateStub <IFileSystemOperation>();

            stubFileSystemOperator.Stub(s => s.FileExists("")).IgnoreArguments().Repeat.Any().Return(true);
            OptimizedTarget target = new OptimizedTarget(null, stubFileSystemOperator);

            bool fileExistResult = target.InitializeConfigFile(installedFilePath, userFilePath);

            Assert.IsTrue(fileExistResult);
        }
コード例 #2
0
        public void InitializeConfigFile_InstalledFileNotExists_ReturnFalse()
        {
            string installedFilePath = "installedFilePath";
            string userFilePath      = "userFilePath";
            IFileSystemOperation stubFileSystemOperator = MockRepository.GenerateStub <IFileSystemOperation>();

            stubFileSystemOperator.Stub(s => s.FileExists(installedFilePath)).Return(false);
            OptimizedTarget target = new OptimizedTarget(null, stubFileSystemOperator);

            bool installedFileNotExistsResult = target.InitializeConfigFile(installedFilePath, userFilePath);

            Assert.IsFalse(installedFileNotExistsResult);
        }
コード例 #3
0
        public void InitializeConfigFile_InstalledFileExists_UserFileNotExists_CopyFileAndReturnTrue()
        {
            string installedFilePath = "installedFilePath";
            string userFilePath      = "userFilePath";
            IFileSystemOperation mockFileSystemOperator = MockRepository.GenerateMock <IFileSystemOperation>();

            mockFileSystemOperator.Stub(s => s.FileExists(installedFilePath)).Return(true);
            mockFileSystemOperator.Stub(s => s.FileExists(userFilePath)).Return(false);
            OptimizedTarget target = new OptimizedTarget(null, mockFileSystemOperator);

            bool installedFileExistsUserFileNotExistsResult = target.InitializeConfigFile(installedFilePath, userFilePath);

            mockFileSystemOperator.AssertWasCalled(s => s.FileCopy(installedFilePath, userFilePath));
            Assert.IsTrue(installedFileExistsUserFileNotExistsResult);
        }
コード例 #4
0
        public void InitializeConfigFile_InstalledFileExists_UserFileNotExists_ThrowException_ReturnFalse()
        {
            string installedFilePath = "installedFilePath";
            string userFilePath      = "userFilePath";
            IFileSystemOperation mockFileSystemOperator = MockRepository.GenerateMock <IFileSystemOperation>();

            mockFileSystemOperator.Stub(s => s.FileExists(installedFilePath)).Return(true);
            mockFileSystemOperator.Stub(s => s.FileExists(userFilePath)).Return(false);
            mockFileSystemOperator.Stub(s => s.FileCopy("", "")).IgnoreArguments().Throw(new Exception());
            OptimizedTarget target = new OptimizedTarget(null, mockFileSystemOperator);

            bool throwExceptionResult = target.InitializeConfigFile(installedFilePath, userFilePath);

            mockFileSystemOperator.AssertWasCalled(s => s.FileCopy(installedFilePath, userFilePath));
            Assert.IsFalse(throwExceptionResult);
        }
コード例 #5
0
 // Used by unit test
 public OptimizedTarget(IHttpClientWrapper httpClientWrapper, IFileSystemOperation fileSystemOperator)
 {
     this._httpClientWrapper  = httpClientWrapper;
     this._fileSystemOperator = fileSystemOperator;
 }
コード例 #6
0
 // Default
 public OptimizedTarget()
 {
     _httpClientWrapper  = new HttpClientWrapper();
     _fileSystemOperator = new FileSystemOperator();
 }