static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var container = new IoCContainer(); container.Register<ICustomerRepository, CustomerXmlRepository>(); container.Register<ICustomerView, CustomerForm>(); var view = container.Resolve<ICustomerView>(); var presenter = new CustomerPresenter(view, container.Resolve<ICustomerRepository>()); Application.Run((Form) view); }
public void CanLoadCustomers() { // arrange var repo = new Mock<ICustomerRepository>(); var view = new Mock<ICustomerView>(); repo.Setup(m => m.GetAll()) .Returns(_stubCustomers).Verifiable(); var presenter = new CustomerPresenter(view.Object, repo.Object); // act // assert repo.Verify(); var customerNames = from c in _stubCustomers select c.Name; view.VerifySet(m => m.CustomerList = customerNames.ToList()); }
public void CanDeleteCustomer() { // arrange var repo = new Mock<ICustomerRepository>(); var view = new Mock<ICustomerView>(); view.Setup(m => m.SelectedCustomer).Returns(1); repo.Setup(m => m.GetAll()) .Returns(_stubCustomers).Verifiable(); var presenter = new CustomerPresenter(view.Object, repo.Object); // act view.Raise(m => m.DeleteCustomer += null, null, null); // assert repo.Verify(m => m.Delete(1), Times.Once()); }