Пример #1
0
        public void Test_AssetTypes_Find()
        {
            IAssetTypesConnector connector = new AssetTypesConnector();

            var newAssetType = new AssetType()
            {
                Description           = "TestAssetType",
                Notes                 = "Some notes",
                Type                  = "1",
                AccountAssetId        = 1150,
                AccountDepreciationId = 7824,
                AccountValueLossId    = 1159,
            };

            var marks = TestUtils.RandomString(3);

            for (var i = 0; i < 5; i++)
            {
                newAssetType.Number = marks + i;
                connector.Create(newAssetType);
                MyAssert.HasNoError(connector);
            }

            var assetTypes = connector.Find();

            Assert.AreEqual(5, assetTypes.Entities.Count(x => x.Number.StartsWith(marks)));

            //restore
            foreach (var entity in assetTypes.Entities.Where(x => x.Number.StartsWith(marks)))
            {
                connector.Delete(entity.Id);
                MyAssert.HasNoError(connector);
            }
        }
Пример #2
0
        public void VatType_Supported()
        {
            var vatTypes = Enum.GetValues(typeof(SupplierVATType)).Cast <SupplierVATType>().ToList();

            ISupplierConnector connector = new SupplierConnector();

            var newSupplier = new Supplier()
            {
                Name = "TestSupplier"
            };

            var supplier = connector.Create(newSupplier);

            MyAssert.HasNoError(connector);

            foreach (var vat in vatTypes)
            {
                supplier.VATType = vat;
                supplier         = connector.Update(supplier);
                MyAssert.HasNoError(connector);
                Assert.AreEqual(vat, supplier.VATType);
            }

            connector.Delete(supplier.SupplierNumber);
        }
Пример #3
0
        public void Test_CompanySettings_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ICompanySettingsConnector connector = new CompanySettingsConnector();

            #region CREATE
            //Not Allowed
            #endregion CREATE

            #region UPDATE
            //Not Allowed
            #endregion UPDATE

            #region READ / GET

            var retrievedCompanySettings = connector.Get();
            MyAssert.HasNoError(connector);
            Assert.IsNotNull(retrievedCompanySettings?.Name);

            #endregion READ / GET

            #region DELETE
            //Not Allowed
            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #4
0
        public void Test_Download_To_Local_System()
        {
            IArchiveConnector connector = new ArchiveConnector();

            //Arrange
            var data           = Resource.fortnox_image;
            var randomFileName = TestUtils.RandomString() + ".txt";

            var fortnoxFile = connector.UploadFile(randomFileName, data, testRootFolder.Name);

            MyAssert.HasNoError(connector);

            //Act
            var localFilePath = TestUtils.GenerateTmpFilePath();
            var fileInfo      = connector.DownloadFile(fortnoxFile.Id, localFilePath);

            MyAssert.HasNoError(connector);
            Assert.IsTrue(fileInfo.Exists);
            Assert.AreEqual(data.Length, fileInfo.Length);

            //Clean
            File.Delete(localFilePath);
            connector.DeleteFile(fortnoxFile.Id);
            MyAssert.HasNoError(connector);
        }
Пример #5
0
        public void Test_PredefinedAccounts_CRUD()
        {
            IPredefinedAccountsConnector connector = new PredefinedAccountsConnector();

            //Get
            var bygAccount = connector.Get("CONSTRUCTION_DEB");

            MyAssert.HasNoError(connector);
            Assert.AreEqual(2647, bygAccount.Account);

            var patentAccount = connector.Get("PRODUCT_DEB");

            MyAssert.HasNoError(connector);
            Assert.AreEqual(2645, patentAccount.Account);

            //Update
            patentAccount.Account = bygAccount.Account;
            connector.Update(patentAccount);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(2647, patentAccount.Account);

            //Revert
            patentAccount.Account = 2645;
            connector.Update(patentAccount);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(2645, patentAccount.Account);
        }
Пример #6
0
        public void Test_Employee_CRUD()
        {
            #region Arrange
            var c             = new EmployeeConnector();
            var alreadyExists = c.Get("TEST_EMP") != null;

            #endregion Arrange

            IEmployeeConnector connector = new EmployeeConnector();

            #region CREATE

            var newEmployee = new Employee()
            {
                EmployeeId    = "TEST_EMP",
                FirstName     = "Test",
                LastName      = "Testasson",
                City          = "Växjö",
                Country       = "Sweden",
                ForaType      = ForaType.A74,
                JobTitle      = "Woodcutter",
                MonthlySalary = 20000
            };

            var createdEmployee = alreadyExists ? connector.Update(newEmployee) : connector.Create(newEmployee);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Test", createdEmployee.FirstName);

            #endregion CREATE

            #region UPDATE

            createdEmployee.FirstName = "UpdatedTest";

            var updatedEmployee = connector.Update(createdEmployee);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTest", updatedEmployee.FirstName);

            #endregion UPDATE

            #region READ / GET

            var retrievedEmployee = connector.Get(createdEmployee.EmployeeId);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTest", retrievedEmployee.FirstName);

            #endregion READ / GET

            #region DELETE

            //Not supported

            #endregion DELETE

            #region Delete arranged resources

            //Add code to delete temporary resources

            #endregion Delete arranged resources
        }
Пример #7
0
        public void Test_Find_Filter()
        {
            IPrintTemplateConnector connector = new PrintTemplateConnector();

            connector.Search.FilterBy = Filter.PrintTemplate.Order;
            var orderTemplates = connector.Find();

            MyAssert.HasNoError(connector);

            Assert.AreEqual(4, orderTemplates.Entities.Count);

            connector.Search.FilterBy = Filter.PrintTemplate.Offer;
            var offerTemplates = connector.Find();

            MyAssert.HasNoError(connector);

            Assert.AreEqual(1, offerTemplates.Entities.Count);

            connector.Search.FilterBy = Filter.PrintTemplate.Invoice;
            var invoiceTemplates = connector.Find();

            MyAssert.HasNoError(connector);

            Assert.AreEqual(9, invoiceTemplates.Entities.Count);
        }
Пример #8
0
        public void Test_Find()
        {
            ILabelConnector connector = new LabelConnector();

            var existingCount = connector.Find().Entities.Count;

            var createdEntries = new List <Label>();

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                var createdEntry = connector.Create(new Label()
                {
                    Description = TestUtils.RandomString()
                });
                createdEntries.Add(createdEntry);
            }

            //Filter not supported
            var fullCollection = connector.Find();

            MyAssert.HasNoError(connector);

            Assert.AreEqual(existingCount + 5, fullCollection.Entities.Count);

            //Limit not supported

            //Delete entries
            foreach (var entry in createdEntries)
            {
                connector.Delete(entry.Id);
            }
        }
Пример #9
0
        public void Test_Customer_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ICustomerConnector connector = new CustomerConnector();

            #region CREATE
            var newCustomer = new Customer()
            {
                Name        = "TestCustomer",
                Address1    = "TestStreet 1",
                Address2    = "TestStreet 2",
                ZipCode     = "01010",
                City        = "Testopolis",
                CountryCode = "SE", //CountryCode needs to be valid
                Email       = "*****@*****.**",
                Type        = CustomerType.Private,
                Active      = false
            };

            var createdCustomer = connector.Create(newCustomer);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestCustomer", createdCustomer.Name);

            #endregion CREATE

            #region UPDATE

            createdCustomer.Name = "UpdatedTestCustomer";

            var updatedCustomer = connector.Update(createdCustomer);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCustomer", updatedCustomer.Name);

            #endregion UPDATE

            #region READ / GET

            var retrievedCustomer = connector.Get(createdCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCustomer", retrievedCustomer.Name);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdCustomer.CustomerNumber);
            MyAssert.HasNoError(connector);

            retrievedCustomer = connector.Get(createdCustomer.CustomerNumber);
            Assert.AreEqual(null, retrievedCustomer, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #10
0
        public void Test_LockedPeriod_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ILockedPeriodConnector connector = new LockedPeriodConnector();

            #region CREATE
            //Not Allowed
            #endregion CREATE

            #region UPDATE
            //Not Allowed
            #endregion UPDATE

            #region READ / GET

            var retrievedLockedPeriod = connector.Get();
            MyAssert.HasNoError(connector);
            Assert.IsNotNull(retrievedLockedPeriod);

            Assert.IsNull(retrievedLockedPeriod.EndDate); //No period is locked

            #endregion READ / GET

            #region DELETE
            //Not Allowed
            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #11
0
        public void Test_Find()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            var testKeyMark = TestUtils.RandomString();

            ISupplierConnector connector = new SupplierConnector();
            var newSupplier = new Supplier()
            {
                Name        = "TestSupplier",
                Address1    = "TestStreet 1",
                Address2    = "TestStreet 2",
                ZipCode     = "01010",
                City        = testKeyMark,
                CountryCode = "SE", //CountryCode needs to be valid
                Email       = "*****@*****.**",
                Active      = false,
                Bank        = "TestBank",
                Currency    = "SEK",
                Phone1      = "01011111345",
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newSupplier);
            }

            //Apply base test filter
            connector.Search.City = testKeyMark;
            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);
            Assert.AreEqual(testKeyMark, fullCollection.Entities.First().City);

            //Apply Limit
            connector.Search.Limit = 2;
            var limitedCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.SupplierNumber);
            }

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
        public void Test_ArticleFileConnection_CRUD()
        {
            #region Arrange

            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle"
            });
            var tmpFile = new ArchiveConnector().UploadFile("tmpImage.png", Resource.fortnox_image);

            #endregion Arrange

            IArticleFileConnectionConnector connector = new ArticleFileConnectionConnector();

            #region CREATE

            var newArticleFileConnection = new ArticleFileConnection()
            {
                FileId        = tmpFile.Id,
                ArticleNumber = tmpArticle.ArticleNumber
            };

            var createdArticleFileConnection = connector.Create(newArticleFileConnection);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(tmpArticle.ArticleNumber, createdArticleFileConnection.ArticleNumber);

            #endregion CREATE

            #region UPDATE

            //Update not supported

            #endregion UPDATE

            #region READ / GET

            var retrievedArticleFileConnection = connector.Get(createdArticleFileConnection.FileId);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(tmpArticle.ArticleNumber, retrievedArticleFileConnection.ArticleNumber);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdArticleFileConnection.FileId);
            MyAssert.HasNoError(connector);

            retrievedArticleFileConnection = connector.Get(createdArticleFileConnection.FileId);
            Assert.AreEqual(null, retrievedArticleFileConnection, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources

            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            new ArchiveConnector().DeleteFile(tmpFile.Id);

            #endregion Delete arranged resources
        }
Пример #13
0
        public void Test_ContractTemplate_CRUD()
        {
            #region Arrange
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle"
            });
            #endregion Arrange

            IContractTemplateConnector connector = new ContractTemplateConnector();

            #region CREATE
            var newContractTemplate = new ContractTemplate()
            {
                ContractLength  = 4,
                Continuous      = false,
                InvoiceInterval = 3,
                InvoiceRows     = new List <ContractTemplateInvoiceRow>()
                {
                    new ContractTemplateInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10
                    }
                },
                TemplateName = "TestTemplate",
            };

            var createdContractTemplate = connector.Create(newContractTemplate);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestTemplate", createdContractTemplate.TemplateName);

            #endregion CREATE

            #region UPDATE

            createdContractTemplate.TemplateName = "UpdatedTestTemplate";

            var updatedContractTemplate = connector.Update(createdContractTemplate);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestTemplate", updatedContractTemplate.TemplateName);

            #endregion UPDATE

            #region READ / GET

            var retrievedContractTemplate = connector.Get(createdContractTemplate.TemplateNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestTemplate", retrievedContractTemplate.TemplateName);

            #endregion READ / GET

            #region DELETE
            //Not supported
            #endregion DELETE

            #region Delete arranged resources
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
Пример #14
0
        public void Test_DueDate()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });
            #endregion Arrange

            IInvoiceConnector connector = new InvoiceConnector();
            var newInvoice = new Invoice()
            {
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceDate    = new DateTime(2019, 1, 20), //"2019-01-20",
                Comments       = "TestInvoice",
                InvoiceRows    = new List <InvoiceRow>()
                {
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15, Price = 100
                    }
                }
            };

            var createdInvoice = connector.Create(newInvoice);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("2019-01-20", createdInvoice.InvoiceDate?.ToString(APIConstants.DateFormat));
            Assert.AreEqual("2019-02-19", createdInvoice.DueDate?.ToString(APIConstants.DateFormat));

            var newInvoiceDate = new DateTime(2019, 1, 1);
            var dateChange     = newInvoiceDate - newInvoice.InvoiceDate.Value;
            var newDueDate     = createdInvoice.DueDate?.AddDays(dateChange.Days);

            createdInvoice.InvoiceDate = newInvoiceDate;
            createdInvoice.DueDate     = newDueDate;

            var updatedInvoice = connector.Update(createdInvoice);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("2019-01-01", updatedInvoice.InvoiceDate?.ToString(APIConstants.DateFormat));
            Assert.AreEqual("2019-01-31", updatedInvoice.DueDate?.ToString(APIConstants.DateFormat));

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
Пример #15
0
        public void Test_Project_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            IProjectConnector connector = new ProjectConnector();

            #region CREATE
            var newProject = new Project()
            {
                Description   = "TestProject",
                Status        = Status.Ongoing,
                StartDate     = new DateTime(2019, 10, 10),
                EndDate       = new DateTime(2021, 10, 10),
                ProjectLeader = "TestProjectLeader",
                ContactPerson = "TestContactPerson",
                Comments      = "TestComments"
            };

            var createdProject = connector.Create(newProject);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestProject", createdProject.Description);

            #endregion CREATE

            #region UPDATE

            createdProject.Description = "UpdatedProject";

            var updatedProject = connector.Update(createdProject);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedProject", updatedProject.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedProject = connector.Get(createdProject.ProjectNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedProject", retrievedProject.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdProject.ProjectNumber);
            MyAssert.HasNoError(connector);

            retrievedProject = connector.Get(createdProject.ProjectNumber);
            Assert.AreEqual(null, retrievedProject, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #16
0
        public void Test_Article_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            IArticleConnector connector = new ArticleConnector();

            #region CREATE
            var newArticle = new Article()
            {
                Description   = "Test Article",
                Height        = 60,
                Width         = 150,
                Type          = ArticleType.Stock,
                PurchasePrice = 2499.50m,
                FreightCost   = 200,
                OtherCost     = 210,
                Note          = "Definitely not worth the price."
            };

            var createdArticle = connector.Create(newArticle);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Test Article", createdArticle.Description);
            #endregion CREATE

            #region UPDATE

            createdArticle.Description = "Updated Test Article";

            var updatedArticle = connector.Update(createdArticle);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Article", updatedArticle.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedArticle = connector.Get(createdArticle.ArticleNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("Updated Test Article", retrievedArticle.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdArticle.ArticleNumber);
            MyAssert.HasNoError(connector);

            retrievedArticle = connector.Get(createdArticle.ArticleNumber);
            Assert.AreEqual(null, retrievedArticle, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #17
0
        public void Test_SalaryTransaction_CRUD()
        {
            #region Arrange
            var tmpEmployee = new EmployeeConnector().Get("TEST_EMP") ?? new EmployeeConnector().Create(new Employee()
            {
                EmployeeId = "TEST_EMP"
            });
            #endregion Arrange

            ISalaryTransactionConnector connector = new SalaryTransactionConnector();

            #region CREATE
            var newSalaryTransaction = new SalaryTransaction()
            {
                EmployeeId = tmpEmployee.EmployeeId,
                SalaryCode = "11", //Arbetstid
                Date       = new DateTime(2020, 1, 1),
                Number     = 10,
                TextRow    = "TestSalaryRow"
            };

            var createdSalaryTransaction = connector.Create(newSalaryTransaction);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestSalaryRow", createdSalaryTransaction.TextRow);

            #endregion CREATE

            #region UPDATE

            createdSalaryTransaction.TextRow = "UpdatedTestSalaryRow";

            var updatedSalaryTransaction = connector.Update(createdSalaryTransaction);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSalaryRow", updatedSalaryTransaction.TextRow);

            #endregion UPDATE

            #region READ / GET

            var retrievedSalaryTransaction = connector.Get(createdSalaryTransaction.SalaryRow);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestSalaryRow", retrievedSalaryTransaction.TextRow);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdSalaryTransaction.SalaryRow);
            MyAssert.HasNoError(connector);

            retrievedSalaryTransaction = connector.Get(createdSalaryTransaction.SalaryRow);
            Assert.AreEqual(null, retrievedSalaryTransaction, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            #endregion Delete arranged resources
        }
Пример #18
0
        public void Test_Find()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            var testKeyMark = TestUtils.RandomString();

            IArticleConnector connector = new ArticleConnector();

            var newArticle = new Article
            {
                Description   = testKeyMark,
                Height        = 60,
                Width         = 150,
                Type          = ArticleType.Stock,
                PurchasePrice = 2499.50m,
                FreightCost   = 200,
                OtherCost     = 210,
                Note          = "Definitely not worth the price."
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newArticle);
            }

            //Apply base test filter
            connector.Search.Description = testKeyMark;
            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            //Apply Limit
            connector.Search.Limit = 2;
            var limitedCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.ArticleNumber);
            }

            #region Delete arranged resources

            //Add code to delete temporary resources

            #endregion Delete arranged resources
        }
Пример #19
0
        public void Test_Find_By_Description()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            IProjectConnector connector = new ProjectConnector();
            var existingEntries         = connector.Find().Entities.Count;
            var description             = TestUtils.RandomString();

            var newProject = new Project()
            {
                Description   = description,
                Status        = Status.Ongoing,
                StartDate     = new DateTime(2019, 10, 10),
                EndDate       = new DateTime(2021, 10, 10),
                ProjectLeader = "TestProjectLeader",
                ContactPerson = "TestContactPerson",
                Comments      = "TestComments"
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newProject);
            }
            var otherDescription = TestUtils.RandomString();
            newProject.Description = otherDescription;
            for (var i = 0; i < 5; i++)
            {
                connector.Create(newProject);
            }

            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(existingEntries + 5 + 5, fullCollection.Entities.Count);
            Assert.AreEqual(5, fullCollection.Entities.Count(e => e.Description == description));
            Assert.AreEqual(5, fullCollection.Entities.Count(e => e.Description == otherDescription));

            //Apply filter
            connector.Search.Description = otherDescription;
            var filteredCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, filteredCollection.TotalResources);
            Assert.AreEqual(5, filteredCollection.Entities.Count);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.ProjectNumber);
            }

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #20
0
        public void Test_ModeOfPayment_CRUD()
        {
            #region Arrange
            var tmpAccount = new AccountConnector().Get(0123) ?? new AccountConnector().Create(new Account()
            {
                Description = "TestAccount", Number = 0123
            });
            #endregion Arrange

            IModeOfPaymentConnector connector = new ModeOfPaymentConnector();

            #region CREATE
            var newModeOfPayment = new ModeOfPayment()
            {
                Description   = "TestMode",
                AccountNumber = tmpAccount.Number,
                Code          = "TEST_MODE",
            };

            var createdModeOfPayment = connector.Create(newModeOfPayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestMode", createdModeOfPayment.Description);

            #endregion CREATE

            #region UPDATE

            createdModeOfPayment.Description = "UpdatedMode";

            var updatedModeOfPayment = connector.Update(createdModeOfPayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedMode", updatedModeOfPayment.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedModeOfPayment = connector.Get(createdModeOfPayment.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedMode", retrievedModeOfPayment.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdModeOfPayment.Code);
            MyAssert.HasNoError(connector);

            retrievedModeOfPayment = connector.Get(createdModeOfPayment.Code);
            Assert.AreEqual(null, retrievedModeOfPayment, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            new AccountConnector().Delete(0123);
            #endregion Delete arranged resources
        }
Пример #21
0
        public void Test_Email()
        {
            #region Arrange
            var cc          = new CustomerConnector();
            var ac          = new ArticleConnector();
            var tmpCustomer = cc.Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis", Email = "*****@*****.**"
            });
            var tmpArticle = ac.Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });
            MyAssert.HasNoError(cc);
            MyAssert.HasNoError(ac);
            #endregion Arrange

            IInvoiceConnector connector = new InvoiceConnector();

            var newInvoice = new Invoice()
            {
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceDate    = new DateTime(2019, 1, 20), //"2019-01-20",
                DueDate        = new DateTime(2019, 2, 20), //"2019-02-20",
                InvoiceType    = InvoiceType.CashInvoice,
                PaymentWay     = PaymentWay.Cash,
                Comments       = "Testing invoice email feature",
                InvoiceRows    = new List <InvoiceRow>()
                {
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20, Price = 100
                    },
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15, Price = 100
                    }
                }
            };

            var createdInvoice = connector.Create(newInvoice);
            MyAssert.HasNoError(connector);

            var emailedInvoice = connector.Email(createdInvoice.DocumentNumber);
            MyAssert.HasNoError(connector);
            Assert.AreEqual(emailedInvoice.DocumentNumber, createdInvoice.DocumentNumber);

            #region Delete arranged resources
            new CustomerConnector().Delete(tmpCustomer.CustomerNumber);
            new ArticleConnector().Delete(tmpArticle.ArticleNumber);
            #endregion Delete arranged resources
        }
Пример #22
0
        public void Test_InvoicePayment_Find()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 10
            });
            var invoiceConnector = new InvoiceConnector();
            var tmpInvoice       = invoiceConnector.Create(new Invoice()
            {
                CustomerNumber = tmpCustomer.CustomerNumber,
                InvoiceDate    = new DateTime(2020, 1, 20),
                DueDate        = new DateTime(2020, 6, 20),
                InvoiceRows    = new List <InvoiceRow>()
                {
                    new InvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 2, Price = 10
                    },
                }
            });
            invoiceConnector.Bookkeep(tmpInvoice.DocumentNumber);
            #endregion Arrange

            IInvoicePaymentConnector connector = new InvoicePaymentConnector();

            var newInvoicePayment = new InvoicePayment()
            {
                InvoiceNumber  = tmpInvoice.DocumentNumber,
                Amount         = 10.5m,
                AmountCurrency = 10.5m,
                PaymentDate    = new DateTime(2020, 2, 1)
            };

            for (var i = 0; i < 5; i++)
            {
                connector.Create(newInvoicePayment);
                MyAssert.HasNoError(connector);
            }

            connector.Search.InvoiceNumber = tmpInvoice.DocumentNumber.ToString();
            var payments = connector.Find();

            Assert.AreEqual(5, payments.Entities.Count);
            Assert.AreEqual(10.5m, payments.Entities.First().Amount);

            foreach (var entity in payments.Entities)
            {
                connector.Delete(entity.Number);
                MyAssert.HasNoError(connector);
            }
        }
Пример #23
0
        public void Test_Expense_CRUD()
        {
            #region Arrange
            var ac = new AccountConnector();
            if (ac.Get(0123) == null) //account 123 does not exist
            {
                ac.Create(new Account()
                {
                    Number = 0123, Description = "TmpAccount"
                });
            }
            #endregion Arrange

            IExpenseConnector connector = new ExpenseConnector();

            #region CREATE

            var newExpense = new Expense()
            {
                Text    = "TestExpense",
                Code    = TestUtils.RandomString(6),
                Account = 0123
            };

            var createdExpense = connector.Create(newExpense);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestExpense", createdExpense.Text);

            #endregion CREATE

            #region UPDATE

            //Not supported

            #endregion UPDATE

            #region READ / GET

            var retrievedExpense = connector.Get(createdExpense.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestExpense", retrievedExpense.Text);

            #endregion READ / GET

            #region DELETE

            //Not supported

            #endregion DELETE

            #region Delete arranged resources
            ac.Delete(0123);
            MyAssert.HasNoError(ac);

            #endregion Delete arranged resources
        }
Пример #24
0
        public void Test_Contract_Find()
        {
            #region Arrange
            var tmpCustomer = new CustomerConnector().Create(new Customer()
            {
                Name = "TmpCustomer", CountryCode = "SE", City = "Testopolis"
            });
            var tmpArticle = new ArticleConnector().Create(new Article()
            {
                Description = "TmpArticle", Type = ArticleType.Stock, PurchasePrice = 100
            });
            #endregion Arrange

            IContractConnector connector = new ContractConnector();

            var newContract = new Contract()
            {
                CustomerNumber = tmpCustomer.CustomerNumber,
                ContractDate   = new DateTime(2019, 1, 20), //"2019-01-20",
                Active         = false,
                Comments       = "TestContract",
                ContractLength = 4,
                Continuous     = true,
                Currency       = "SEK",
                Language       = Language.English,
                InvoiceRows    = new List <ContractInvoiceRow>()
                {
                    new ContractInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 10
                    },
                    new ContractInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 20
                    },
                    new ContractInvoiceRow()
                    {
                        ArticleNumber = tmpArticle.ArticleNumber, DeliveredQuantity = 15
                    }
                },
                PeriodStart = new DateTime(2020, 01, 01),
                PeriodEnd   = new DateTime(2020, 03, 01)
            };

            for (var i = 0; i < 5; i++)
            {
                connector.Create(newContract);
                MyAssert.HasNoError(connector);
            }

            connector.Search.CustomerNumber = tmpCustomer.CustomerNumber;
            var contracts = connector.Find();
            Assert.AreEqual(5, contracts.Entities.Count);
            Assert.AreEqual("INACTIVE", contracts.Entities.First().Status);
        }
Пример #25
0
        public void Test_Find()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            var testKeyMark = TestUtils.RandomInt();

            IAccountConnector connector = new AccountConnector();
            var newAccount = new Account()
            {
                Description        = "Test Account",
                Active             = false,
                CostCenterSettings = CostCenterSettings.Allowed,
                ProjectSettings    = ProjectSettings.Allowed,
                SRU = testKeyMark
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                newAccount.Number = GetUnusedAccountNumber();
                connector.Create(newAccount);
                MyAssert.HasNoError(connector);
            }

            //Apply base test filter
            connector.SRU = testKeyMark.ToString();
            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            //Apply Limit
            connector.Limit = 2;
            var limitedCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.Number);
            }
            #region Delete arranged resources

            //Add code to delete temporary resources

            #endregion Delete arranged resources
        }
Пример #26
0
        public void Test_CostCenter_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ICostCenterConnector connector = new CostCenterConnector();

            #region CREATE
            var newCostCenter = new CostCenter()
            {
                Code        = TestUtils.RandomString(5),
                Description = "TestCostCenter",
                Active      = true,
                Note        = "Some notes"
            };

            var createdCostCenter = connector.Create(newCostCenter);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestCostCenter", createdCostCenter.Description);

            #endregion CREATE

            #region UPDATE

            createdCostCenter.Description = "UpdatedTestCostCenter";

            var updatedCostCenter = connector.Update(createdCostCenter);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCostCenter", updatedCostCenter.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedCostCenter = connector.Get(createdCostCenter.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestCostCenter", retrievedCostCenter.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdCostCenter.Code);
            MyAssert.HasNoError(connector);

            retrievedCostCenter = connector.Get(createdCostCenter.Code);
            Assert.AreEqual(null, retrievedCostCenter, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #27
0
        public void Test_Find()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ICostCenterConnector connector = new CostCenterConnector();
            var newCostCenter = new CostCenter()
            {
                Code        = TestUtils.RandomString(),
                Description = "TestCostCenter",
                Active      = true,
                Note        = "Some notes"
            };

            //Add entries
            for (var i = 0; i < 5; i++)
            {
                newCostCenter.Code = TestUtils.RandomString(5);
                connector.Create(newCostCenter);
                MyAssert.HasNoError(connector);
            }

            //Apply base test filter
            connector.Search.LastModified = DateTime.Now.AddMinutes(-5);
            var fullCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, fullCollection.TotalResources);
            Assert.AreEqual(5, fullCollection.Entities.Count);
            Assert.AreEqual(1, fullCollection.TotalPages);

            Assert.AreEqual("TestCostCenter", fullCollection.Entities[0].Description);

            //Apply Limit
            connector.Search.Limit = 2;
            var limitedCollection = connector.Find();
            MyAssert.HasNoError(connector);

            Assert.AreEqual(5, limitedCollection.TotalResources);
            Assert.AreEqual(2, limitedCollection.Entities.Count);
            Assert.AreEqual(3, limitedCollection.TotalPages);

            //Delete entries
            foreach (var entry in fullCollection.Entities)
            {
                connector.Delete(entry.Code);
            }
            #region Delete arranged resources

            //Add code to delete temporary resources

            #endregion Delete arranged resources
        }
Пример #28
0
        public void Test_Unit_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            IUnitConnector connector = new UnitConnector();

            #region CREATE
            var newUnit = new Unit()
            {
                Code        = "TST",
                Description = "TestUnit"
            };

            var createdUnit = connector.Create(newUnit);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestUnit", createdUnit.Description);

            #endregion CREATE

            #region UPDATE

            createdUnit.Description = "UpdatedTestUnit";

            var updatedUnit = connector.Update(createdUnit);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestUnit", updatedUnit.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedUnit = connector.Get(createdUnit.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestUnit", retrievedUnit.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdUnit.Code);
            MyAssert.HasNoError(connector);

            retrievedUnit = connector.Get(createdUnit.Code);
            Assert.AreEqual(null, retrievedUnit, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #29
0
        public void Test_TermsOfPayment_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            ITermsOfPaymentConnector connector = new TermsOfPaymentConnector();

            #region CREATE
            var newTermsOfPayment = new TermsOfPayment()
            {
                Code        = TestUtils.RandomString(5),
                Description = "TestPaymentTerms"
            };

            var createdTermsOfPayment = connector.Create(newTermsOfPayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestPaymentTerms", createdTermsOfPayment.Description);

            #endregion CREATE

            #region UPDATE

            createdTermsOfPayment.Description = "UpdatedTestPaymentTerms";

            var updatedTermsOfPayment = connector.Update(createdTermsOfPayment);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestPaymentTerms", updatedTermsOfPayment.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedTermsOfPayment = connector.Get(createdTermsOfPayment.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestPaymentTerms", retrievedTermsOfPayment.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdTermsOfPayment.Code);
            MyAssert.HasNoError(connector);

            retrievedTermsOfPayment = connector.Get(createdTermsOfPayment.Code);
            Assert.AreEqual(null, retrievedTermsOfPayment, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }
Пример #30
0
        public void Test_WayOfDelivery_CRUD()
        {
            #region Arrange
            //Add code to create required resources
            #endregion Arrange

            IWayOfDeliveryConnector connector = new WayOfDeliveryConnector();

            #region CREATE
            var newWayOfDelivery = new WayOfDelivery()
            {
                Code        = "TST",
                Description = "TestDeliveryMethod"
            };

            var createdWayOfDelivery = connector.Create(newWayOfDelivery);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("TestDeliveryMethod", createdWayOfDelivery.Description);

            #endregion CREATE

            #region UPDATE

            createdWayOfDelivery.Description = "UpdatedTestDeliveryMethod";

            var updatedWayOfDelivery = connector.Update(createdWayOfDelivery);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestDeliveryMethod", updatedWayOfDelivery.Description);

            #endregion UPDATE

            #region READ / GET

            var retrievedWayOfDelivery = connector.Get(createdWayOfDelivery.Code);
            MyAssert.HasNoError(connector);
            Assert.AreEqual("UpdatedTestDeliveryMethod", retrievedWayOfDelivery.Description);

            #endregion READ / GET

            #region DELETE

            connector.Delete(createdWayOfDelivery.Code);
            MyAssert.HasNoError(connector);

            retrievedWayOfDelivery = connector.Get(createdWayOfDelivery.Code);
            Assert.AreEqual(null, retrievedWayOfDelivery, "Entity still exists after Delete!");

            #endregion DELETE

            #region Delete arranged resources
            //Add code to delete temporary resources
            #endregion Delete arranged resources
        }