public void TestCreateController()
        {
            Client client;

            client = GetSomeClient();
            ClientInvoicesModel model = new ClientInvoicesModel(client);

            _controller.OpenView(model);

            Assert.IsNotNull(_mainController.CurrentView);
        }
        public void TestCreateController()
        {
            Client client;

            client = GetSomeClient();
            ClientInvoicesModel model = new ClientInvoicesModel(client);

            _controller.OpenView(model);

            Assert.IsNotNull(_mainController.CurrentView);
            Assert.AreEqual(client, ((ModelSingleEntityBase <Client>)_mainController.CurrentView.Model).Entity);
        }
        public void TestBeginEdit()
        {
            Client client;

            client = GetSomeClient();
            ClientInvoicesModel model = new ClientInvoicesModel(client);

            _controller.OpenView(model);

            Assert.AreEqual(EntityStatus.Clean, client.Status);
            model.BeginEdit();
            Assert.AreEqual(EntityStatus.Dirty, client.Status);
        }
        public void TestCancelEdit()
        {
            Client client;
            string originalName;

            client       = GetSomeClient();
            originalName = client.Name;
            ClientInvoicesModel model = new ClientInvoicesModel(client);

            _controller.OpenView(model);

            //_controller.BeginEdit(_mainController.CurrentView, client);
            client.Name = "new name";
            Assert.AreEqual("new name", client.Name);
            //_controller.CancelEdit(_mainController.CurrentView, client);
            Assert.AreEqual(originalName, client.Name);
            Assert.AreEqual(EntityStatus.Clean, client.Status);
        }
        public void TestEndEdit()
        {
            EntityList <Invoice> invoices;

            invoices = _invoiceAdapter.LoadByObjectQuery(new OQuery <Invoice>());
            InvoicesModel invModel = new InvoicesModel(invoices);

            _controller.OpenView(invModel);
            Assert.IsNotNull(_sideController.CurrentView);
            Assert.AreSame(invModel, _sideController.CurrentView.Model);

            Client client;

            client = GetSomeClient();
            client.Invoices.AddRange(_invoiceAdapter.LoadByObjectQuery(new OQuery <Invoice>()));
            ClientInvoicesModel model = new ClientInvoicesModel(client);

            _controller.OpenView(model);

            Invoice inv;

            inv = invoices[3];
            Assert.IsTrue(model.HasEntity(inv.Id));

            _controller.BeginEdit(_sideController.CurrentView, inv);
            double originalAmount = inv.Amount;

            inv.Amount = 99.0;

            _controller.EndEdit(_sideController.CurrentView, inv);
            Invoice inv2;

            inv2 = (Invoice)model.GetEntity(inv.Id);
            Assert.IsNotNull(inv2);
            Assert.AreEqual(inv, inv2);
            Assert.AreNotSame(inv2, inv);
            Assert.AreEqual(99.0, inv2.Amount);
        }