static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var config = new Configuration(); var storage = new DropBoxStorage( config ); var model = new GuiModel(storage); MainWindow main_window = new MainWindow(); GuiPresenter presenter = new GuiPresenter( main_window, model ); main_window.SetPresenter(presenter); Application.Run( main_window ); }
public void TestPresenterAddFile() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.Connect(); string test_file_path = "some path"; var test_hierarchy = new List<string>{"str1", "str2" }; presenter.AddFileToUpload( test_hierarchy, test_file_path ); Assert.AreEqual(test_file_path, test_model.file_path); Assert.AreEqual(test_hierarchy, test_model.hierarchy); }
public void TestDownloadFile() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.Connect(); var test_file_path = new List<string> { "str1", "str2", "some file" }; presenter.NodeSelected(test_file_path); presenter.LoadAction(); Assert.AreEqual(test_file_path, test_model.hierarchy); }
public void TestNodeTypeSelection() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.Connect(); presenter.NodeSelected(new List<string> { "2.1" }); Assert.IsFalse(test_view.add_files_button_enabled); presenter.NodeSelected(new List<string> { "1.1" }); Assert.IsTrue(test_view.add_files_button_enabled); presenter.NodeSelected(new List<string> { "1.2" }); Assert.IsFalse(test_view.add_files_button_enabled); }
public void TestLoadButtonText() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.Connect(); presenter.NodeSelected(new List<string> { "2.1" }); Assert.AreEqual("Decrypt and Download", test_view.load_button_text); presenter.NodeSelected(new List<string> { "1.1" }); Assert.AreEqual("Encrypt and LoadAction", test_view.load_button_text); presenter.NodeSelected(new List<string> { "1.2" }); Assert.AreEqual("Decrypt and Download", test_view.load_button_text); }
public void TestPresenterConnect() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); var root_dir = presenter.Connect(); Assert.AreEqual( "Disconnect", test_view.connection_button_text ); CollectionAssert.AreEqual( new string[]{"1.1", "1.2"}, root_dir.Keys.ToArray() ); CollectionAssert.AreEqual(new List<string>{ "2.1" }, root_dir.Values.ElementAt(0)); Assert.AreEqual(null, root_dir.Values.ElementAt(1)); Assert.IsTrue(test_view.add_files_button_enabled); Assert.IsTrue(test_view.upload_button_enabled); }
public void TestPresenterUpload() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.NodeSelected(new List<string>{"1.1"}); presenter.LoadAction(); Assert.IsTrue(test_model.uploaded); test_model.uploaded = false; presenter.NodeSelected(new List<string>{"2.1"}); presenter.LoadAction(); Assert.IsFalse(test_model.uploaded); }
public void TestPresenterInitialization() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter( test_view, test_model ); Assert.AreEqual("Connect", test_view.connection_button_text); Assert.AreEqual("Encrypt and LoadAction", test_view.load_button_text); Assert.IsFalse(test_view.add_files_button_enabled); Assert.IsFalse(test_view.upload_button_enabled); }
public void TestPresenterDisonnect() { TestView test_view = new TestView(); TestModel test_model = new TestModel(); IPresenter presenter = new GuiPresenter(test_view, test_model); presenter.Connect(); presenter.Disconnect(); Assert.AreEqual("Connect", test_view.connection_button_text); Assert.IsTrue(test_view.tree_cleared); Assert.IsFalse(test_view.add_files_button_enabled); Assert.IsFalse(test_view.upload_button_enabled); }