Exemple #1
0
        public void EntityController_Update_WithNoFieldsAltered_Succeeds()
        {
            var controllerMock = new ApiConnectionEntityControllerMock();
            var connector      = new ApiConnectorMock();
            var controllerList = new ControllerList(connector, "https://start.exactonline.nl/api/v1/");

            var invoice = new SalesInvoice {
                Description = "New Description"
            };
            var line = new SalesInvoiceLine {
                Description = "Invoice Line"
            };

            invoice.SalesInvoiceLines = new List <SalesInvoiceLine> {
                line
            };

            var controller       = (Controller <SalesInvoice>)controllerList.GetController <SalesInvoice>();
            var entityController = new EntityController(invoice, "ID", invoice.InvoiceID.ToString(), controllerMock, controller.GetEntityController);
            var returnValue      = controller.AddEntityToManagedEntitiesCollection(invoice);

            Assert.IsTrue(returnValue);

            entityController.Update(invoice);
            string data = controllerMock.Data;

            Assert.AreEqual("", data);
        }
Exemple #2
0
        public void EntityController_Update_WithExistingLinkedEntity_Succeeds()
        {
            var controllerMock = new ApiConnectionEntityControllerMock();
            var connector      = new ApiConnectorMock();
            var controllerList = new ControllerList(connector, "https://start.exactonline.nl/api/v1/");

            var invoice = new SalesInvoice {
                Description = "New Description"
            };
            var line = new SalesInvoiceLine {
                Description = "InvoiceLine"
            };

            invoice.SalesInvoiceLines = new List <SalesInvoiceLine> {
                line
            };

            var controller       = (Controller <SalesInvoice>)controllerList.GetController <SalesInvoice>();
            var entityController = new EntityController(invoice, "ID", invoice.InvoiceID.ToString(), controllerMock, controller.GetEntityController);

            Assert.IsTrue(controller.AddEntityToManagedEntitiesCollection(invoice));

            // Change State
            invoice.Description = "Description2";
            line.Description    = "InvoiceLine2";

            entityController.Update(invoice);
            string data = controllerMock.Data;

            Assert.AreEqual(@"{""Description"":""Description2"",""SalesInvoiceLines"":[{""Description"":""InvoiceLine2""}]}", data);
        }
Exemple #3
0
        public void EntityController_Update_WithNewLinkedEntity_Succeeds()
        {
            var controllerMock   = new ApiConnectionEntityControllerMock();
            var apiConnectorMock = new ApiConnectorMock();
            var controllerList   = new ControllerList(apiConnectorMock, "https://start.exactonline.nl/api/v1/");

            var controller = (Controller <SalesInvoice>)controllerList.GetController <SalesInvoice>();
            var invoice    = new SalesInvoice {
                Description = "New Description"
            };
            var entityController = new EntityController(invoice, "ID", invoice.InvoiceID.ToString(), controllerMock, controller.GetEntityController);

            // Change State
            invoice.Description = "Description2";
            var line = new SalesInvoiceLine {
                Description = "InvoiceLine2"
            };

            invoice.SalesInvoiceLines = new List <SalesInvoiceLine> {
                line
            };

            entityController.Update(invoice);

            string data = controllerMock.Data;

            Assert.IsTrue(data.Contains(@"""Description"":""Description2"""));
            Assert.IsTrue(data.Contains(@"""Description"":""InvoiceLine2"""));
        }
Exemple #4
0
        public void EntityController_Update_WithOnlyLinkedEntityFieldsAltered_Succeeds()
        {
            var controllerMock = new ApiConnectionEntityControllerMock();
            var connector      = new ApiConnectorMock();
            var controllerList = new ControllerList(connector, "https://start.exactonline.nl/api/v1/");

            var invoice = new SalesInvoice {
                Description = "New Description"
            };
            var line = new SalesInvoiceLine {
                Description = "InvoiceLine"
            };

            invoice.SalesInvoiceLines = new List <SalesInvoiceLine> {
                line
            };

            var controller = (Controller <SalesInvoice>)controllerList.GetController <SalesInvoice>();
            var ec         = new EntityController(invoice, "ID", invoice.InvoiceID.ToString(), controllerMock, controller.GetEntityController);

            Assert.IsTrue(controller.AddEntityToManagedEntitiesCollection(invoice));

            // Change State
            line.Description = "InvoiceLine2";
            ec.Update(invoice);

            string       result   = controllerMock.Data;
            const string expected = "{\"SalesInvoiceLines\":[{\"Description\":\"InvoiceLine2\"}]}";

            Assert.AreEqual(expected, result);
        }
        private static void CreateLinkedObjects()
        {
            for (int i = 0; i < 100; i++)
            {
                // Create Object
                var newInvoice = new SalesInvoice
                {
                    Currency    = "EUR",
                    OrderDate   = new DateTime(2012, 10, 26),
                    InvoiceTo   = new Guid("3734121e-1544-4b77-9ae2-7203e9bd6046"),
                    Journal     = "50",
                    OrderedBy   = new Guid("3734121e-1544-4b77-9ae2-7203e9bd6046"),
                    Description = "New invoice for Entity With Collection"
                };

                var newInvoiceLine = new SalesInvoiceLine
                {
                    Description = "New invoice line for Entity With Collection",
                    Item        = new Guid("4f68481a-7a2c-4fbc-a3a0-0c494df3fa0d")
                };

                var invoicelines = new List <SalesInvoiceLine> {
                    newInvoiceLine
                };
                newInvoice.SalesInvoiceLines = invoicelines;

                // Set Mock Connection and Create object
                var controllerMock = new ApiConnectionEntityControllerMock();
                var controller     = new Controller <SalesInvoice>(controllerMock);
                controller.Create(ref newInvoice, true);
            }
        }
        private static void CreateEmptyLinkedEntities()
        {
            for (int i = 0; i < 100; i++)
            {
                // Create Object
                var newInvoice = new SalesInvoice
                {
                    Currency    = "EUR",
                    OrderDate   = new DateTime(2012, 10, 26),
                    InvoiceTo   = new Guid("3734121e-1544-4b77-9ae2-7203e9bd6046"),
                    Journal     = "50",
                    OrderedBy   = new Guid("3734121e-1544-4b77-9ae2-7203e9bd6046"),
                    Description = "New invoice for Entity With Collection"
                };

                // Set Mock Connection and Create object
                var controllerMock = new ApiConnectionEntityControllerMock();
                var controller     = new Controller <SalesInvoice>(controllerMock);
                controller.Create(ref newInvoice, true);
            }
        }