public void GetFile_ReturnsDifferent_TempFile_IfVersionsDiffer()
        {
            var creator = myMockery.NewMock<ITempFileCreator> ();

            var cache = new TempFileCache (creator);
            var file1 = myMockery.NewMock<IFileWithHistory> ();
            string filename = "/tmp/test_repo/use_cases.odt";

            Stub.On (file1).GetProperty ("Path").Will (Return.Value (filename));

            var version = myMockery.NewMock<IFileVersion> ();
            Stub.On (version).GetProperty ("ID").Will (Return.Value ("0475abdb01ed08f8997986e319e2467b"));
            var version2 = myMockery.NewMock<IFileVersion> ();
            Stub.On (version2).GetProperty ("ID").Will (Return.Value ("72311666ba461988b1264f6f5e368d17"));

            Stub.On (creator).Method ("CreateTempFileFromVersion").With (file1, version).Will (Return.Value (filename));
            Stub.On (creator).Method ("CreateTempFileFromVersion").With (file1, version2).Will (Return.Value (filename  + "2"));

            Assert.AreNotEqual (cache.GetFile (file1, version), cache.GetFile (file1, version2));
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            Application.Init ();

            ChangeCurrentDirectoryToExePath ();

            Catalog.Init ("i18n", "locale");

            var git = new DirectoryHistory.History.Git.HistoryProvider ();
            var gitCreator = new DirectoryHistory.History.Git.TempFileCreator (git);
            var cache = new TempFileCache (gitCreator);

            var context = new ApplicationContext () {
                Provider = git,
                TempFileCache = cache,
                ExceptionHandling = new ExceptionHandling (new ExceptionOccuredDialog ())
            };

            var applLogic = new ApplicationLogic (context);

            MainWindow win = new MainWindow (applLogic);
            win.Show ();
            Application.Run ();
        }
        public void GetFile_ReturnsTheCached_File()
        {
            var creator = myMockery.NewMock<ITempFileCreator> ();

            var cache = new TempFileCache (creator);
            var file1 = myMockery.NewMock<IFileWithHistory> ();
            string filename = "/tmp/test_repo/use_cases.odt";

            Stub.On (creator).Method ("CreateTempFileFromVersion").Will (Return.Value (filename));

            Stub.On (file1).GetProperty ("Path").Will (Return.Value (filename));

            var file2 = myMockery.NewMock<IFileWithHistory> ();
            Stub.On (file2).GetProperty ("Path").Will (Return.Value (filename));

            var version = myMockery.NewMock<IFileVersion> ();
            Stub.On (version).GetProperty ("ID").Will (Return.Value ("0475abdb01ed08f8997986e319e2467b"));

            Assert.AreEqual (cache.GetFile (file1, version), cache.GetFile (file2, version));
        }
 public ApplicationLogic(ApplicationContext context)
 {
     HistoryProvider = context.Provider;
     tempFileCache = context.TempFileCache;
     ExceptionHandling = context.ExceptionHandling;
 }