public void Copy_Source_Is_File_Success()
        {
            var sourceFile = Utilities.GetRandomString();
            var targetFile = Utilities.GetRandomString();

            MockDirectoryService.Stub(mock => mock.Exists(Arg.Is(sourceFile)))
            .Return(false);
            MockDirectoryService.Stub(mock => mock.Exists(Arg.Is(targetFile)))
            .Return(false);

            var mockSourceFile = MockRepository.GenerateMock <IFile>();

            MockFileService.Stub(mock => mock.Exists(Arg.Is(sourceFile)))
            .Return(true);
            MockFileService.Stub(mock => mock.OpenFile(Arg.Is(sourceFile)))
            .Return(mockSourceFile);
            MockFileService.Stub(mock => mock.Exists(Arg.Is(targetFile)))
            .Return(false);

            MockFileService.Expect(mock => mock.Copy(Arg <File> .Is.Anything, Arg.Is(targetFile)))
            .Return(MockRepository.GenerateStub <IFile>());

            // Act
            var result = DispatchService.Copy(sourceFile, targetFile);

            // Assert
            Assert.IsTrue(result);
            MockFileService.VerifyAllExpectations();
        }
        public void Copy_Source_Is_Directory_Success()
        {
            var sourceDir = Utilities.GetRandomString();
            var targetDir = Utilities.GetRandomString();

            var mockSourceDir = MockRepository.GenerateMock <IDirectory>();
            var mockTargetDir = MockRepository.GenerateMock <IDirectory>();

            mockSourceDir.Expect(mock => mock.CopyTo(Arg.Is(targetDir)))
            .Return(mockTargetDir);

            MockDirectoryService.Stub(mock => mock.Exists(Arg.Is(sourceDir)))
            .Return(true);
            MockDirectoryService.Stub(mock => mock.OpenDirectory(Arg.Is(sourceDir)))
            .Return(mockSourceDir);

            MockDirectoryService.Stub(mock => mock.Exists(Arg.Is(targetDir)))
            .Return(false);

            MockFileService.Stub(mock => mock.Exists(Arg.Is(sourceDir)))
            .Return(false);
            MockFileService.Stub(mock => mock.Exists(Arg.Is(targetDir)))
            .Return(false);

            // Act
            var result = DispatchService.Copy(sourceDir, targetDir);

            // Assert
            Assert.IsTrue(result);
            mockSourceDir.VerifyAllExpectations();
        }
        public void FileCount()
        {
            var          service      = new MockFileService();
            ReportViewer reportViewer = new ReportViewer(service);

            reportViewer.PrepareData();


            Assert.AreEqual(1, service.count_tmpFiles);
        }
Example #4
0
        public void Init()
        {
            method = MockMethod.CreateMockMethodWithoutAnyAttributes();
            method.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs";

            treeView = new MockTestTreeView();
            treeView.SelectedMember     = method;
            fileService                 = new MockFileService();
            gotoDefinitionCommand       = new GotoDefinitionCommand(fileService);
            gotoDefinitionCommand.Owner = treeView;
            gotoDefinitionCommand.Run();
        }
        public void Init()
        {
            MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();

            c.CompilationUnit.FileName = @"c:\projects\mytest.cs";

            treeView = new MockTestTreeView();
            treeView.SelectedClass      = c;
            fileService                 = new MockFileService();
            gotoDefinitionCommand       = new GotoDefinitionCommand(fileService);
            gotoDefinitionCommand.Owner = treeView;
            gotoDefinitionCommand.Run();
        }
        public async Task Initialize()
        {
            this.accessList = new MockStorageItemAccessList();
            this.accessList.Add(
                new MockStorageFile {
                Name = "Some Metadata"
            },
                "Some Metadata"
                );

            this.accessList.Add(
                new MockStorageFile {
                Name = "Some more metadata"
            },
                "Some more metadata"
                );

            this.badFileToken = this.accessList.Add(
                null,
                "Bad"
                );

            this.accessList.Add(
                new MockStorageFile {
                Name = "A test file"
            },
                "A test file"
                );

            this.proxyFileName = "temp.txt";
            StorageFile proxy = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(this.proxyFileName, CreationCollisionOption.OpenIfExists);

            this.accessList.Add(
                proxy.AsWrapper(),
                this.proxyFileName
                );

            this.proxyProvider = new FileProxyProvider(ApplicationData.Current.TemporaryFolder);
            IFileAccessService fileService = new MockFileService();

            this.promptingService = new MockUserPromptingService();
            this.viewModel        = new DashboardViewModel(
                this.accessList,
                new MockMotdProvider(),
                this.proxyProvider,
                new FileExportService(this.accessList, fileService),
                this.promptingService,
                this.promptingService,
                fileService
                );
        }
        public void Init()
        {
            method = MockMethod.CreateMockMethodWithoutAnyAttributes();
            method.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs";

            int methodBeginLine   = 3;           // 1 based.
            int methodBeginColumn = 6;           // 1 based.

            method.Region = new DomRegion(methodBeginLine, methodBeginColumn);

            treeView = new MockTestTreeView();
            treeView.SelectedMember     = method;
            fileService                 = new MockFileService();
            gotoDefinitionCommand       = new GotoDefinitionCommand(fileService);
            gotoDefinitionCommand.Owner = treeView;
            gotoDefinitionCommand.Run();
        }
        public void Init()
        {
            MockClass c = MockClass.CreateMockClassWithoutAnyAttributes();

            c.CompilationUnit.FileName = @"c:\projects\mytest.cs";

            int beginLine   = 3;           // 1 based.
            int beginColumn = 6;           // 1 based.

            c.Region = new DomRegion(beginLine, beginColumn);

            treeView = new MockTestTreeView();
            treeView.SelectedClass      = c;
            fileService                 = new MockFileService();
            gotoDefinitionCommand       = new GotoDefinitionCommand(fileService);
            gotoDefinitionCommand.Owner = treeView;
            gotoDefinitionCommand.Run();
        }
Example #9
0
        public void Init()
        {
            baseClassMethod = MockMethod.CreateMockMethodWithoutAnyAttributes();
            baseClassMethod.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs";

            MockClass derivedClass = MockClass.CreateMockClassWithoutAnyAttributes();

            derivedClass.CompilationUnit.FileName = @"d:\projects\myderivedtestclass.cs";

            int methodBeginLine   = 3;           // 1 based.
            int methodBeginColumn = 6;           // 1 based.

            baseClassMethod.Region = new DomRegion(methodBeginLine, methodBeginColumn);

            BaseTestMember baseTestMethod = new BaseTestMember(derivedClass, baseClassMethod);

            treeView = new MockTestTreeView();
            treeView.SelectedMember     = baseTestMethod;
            fileService                 = new MockFileService();
            gotoDefinitionCommand       = new GotoDefinitionCommand(fileService);
            gotoDefinitionCommand.Owner = treeView;
            gotoDefinitionCommand.Run();
        }
        public async Task Init()
        {
            StorageFolder rootFolder = ApplicationData.Current.TemporaryFolder;

            rootFolder = await rootFolder.CreateFolderAsync("Proxies", CreationCollisionOption.OpenIfExists);

            this.proxyProvider = new FileProxyProvider(rootFolder);
            Assert.AreEqual(0, (await rootFolder.GetFilesAsync()).Count, "Test should start with no proxies");

            IDatabaseAccessList accessList = new MockStorageItemAccessList();

            this.promptService = new MockUserPromptingService();
            IFileAccessService fileService = new MockFileService();

            this.viewModelFactory = new CachedFilesViewModelFactory(
                accessList,
                new FileExportService(accessList, fileService),
                this.proxyProvider,
                this.promptService,
                this.promptService,
                fileService
                );
        }
Example #11
0
 public void EnsureFileExists(string path, byte[] contents) => MockFileService.WriteAllBytes(path, contents);
Example #12
0
 public void EnsureFileExists(string path, string contents = "") => MockFileService.WriteAllText(path, contents);
		public void Init()
		{
			fileService = new MockFileService();
		}
 public void Init()
 {
     fileService = new MockFileService();
 }