Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        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);
        }