コード例 #1
0
ファイル: Program.cs プロジェクト: abdelkader/vCardEditor
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var fileHandler = new FileHandler();
            var mainForm = new MainForm();
            var presenter = new MainPresenter(mainForm, new ContactRepository(fileHandler));

            Application.Run(mainForm);
        }
コード例 #2
0
        public void DeleteTest()
        {
            var handler = new Mock<IFileHandler>();
            var repo = new Mock<ContactRepository>(handler.Object);
            var view = new Mock<IMainView>();
            handler.Setup(x => x.ReadAllLines("filename"))
                    .Returns(vcfThreeEntry);

            var presenter = new MainPresenter(view.Object, repo.Object);
            view.Raise(m => m.NewFileOpened += null, new EventArg<string>("filename"));

            //Mouse click on second row.
            repo.Object.Contacts[1].isSelected = true;

            //Delete the second one.
            view.Raise(m => m.DeleteContact += null, null, null);

            Assert.AreEqual(repo.Object.Contacts.Count, 2);
            Assert.AreEqual(repo.Object.Contacts[1].card.FormattedName, "Jean Dupont3");
        }
コード例 #3
0
        public void NewFileOpenedTest()
        {
            var handler = new Mock<IFileHandler>();
            var repo = new Mock<ContactRepository>(handler.Object);
            var view = new Mock<IMainView>();
            handler.Setup(x => x.ReadAllLines("filename"))
                    .Returns(vcfOneEntry);

            var presenter = new MainPresenter(view.Object, repo.Object);
            view.Raise(m => m.NewFileOpened += null, new EventArg<string>("filename"));

            view.Verify(m => m.DisplayContacts(It.Is<BindingList<Contact>>(x => x.Count == 1)));
            view.Verify(m => m.DisplayContacts(It.Is<BindingList<Contact>>(x => x[0].card.FormattedName == "Jean Dupont1")));
        }