Ejemplo n.º 1
0
        public void InsertOrUpdateLOVItemTest()
        {
            // Tested in FindLOVItemModelTest and multiple other tests, but
            // with extra tests here

            // Get a test user
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);
            var lov         = GetRandomLOV(testCompany.Id);

            // Create some LOV items
            var testItem1 = createLOVItem(testCompany, lov);
            var error     = LookupService.InsertOrUpdateLOVItem(testItem1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindLOVItem(testItem1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testItem1, testModel);


            var testItem2 = createLOVItem(testCompany, lov);

            error = LookupService.InsertOrUpdateLOVItem(testItem2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindLOVItem(testItem2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testItem2, testModel);


            // Try to create an item with the same text
            var dupItem = LookupService.Clone(testItem1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateLOVItem(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate LOVItem returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockLOVItem(testItem1);

            testItem1.ItemText = RandomString();
            error = LookupService.InsertOrUpdateLOVItem(testItem1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename the item to an existing item text (should fail)
            lgs = LookupService.LockLOVItem(testItem1);

            testItem1.ItemText = testItem2.ItemText;
            error = LookupService.InsertOrUpdateLOVItem(testItem1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming an LOVItem to the same name as an existing LOVItem returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 2
0
        public void InsertOrUpdateDocumentTemplateTest()
        {
            // Tested in DeleteDocumentTemplateTest, but additional tests here
            var testUser     = GetTestUser();
            var testCompany  = GetTestCompany(testUser);
            var testCurrency = db.FindCurrency("AUD");

            var testDocumentTemplate1 = createDocumentTemplate(testCompany, DocumentTemplateCategory.Invoice, DocumentTemplateType.None);
            var error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindDocumentTemplate(testDocumentTemplate1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testDocumentTemplate1, testModel);

            var testDocumentTemplate2 = createDocumentTemplate(testCompany, DocumentTemplateCategory.Pickslip, DocumentTemplateType.None);

            error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindDocumentTemplate(testDocumentTemplate2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testDocumentTemplate2, testModel);


            // Try to create a DocumentTemplate with the same name
            var dupItem = LookupService.Clone(testDocumentTemplate1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateDocumentTemplate(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate DocumentTemplate returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockDocumentTemplate(testDocumentTemplate1);

            testDocumentTemplate1.Name = RandomString();
            error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockDocumentTemplate(testDocumentTemplate1);

            testDocumentTemplate1.Name = testDocumentTemplate2.Name;
            error = LookupService.InsertOrUpdateDocumentTemplate(testDocumentTemplate1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a DocumentTemplate to the same name as an existing DocumentTemplate returned no error when it should have returned a 'duplicate' error");
        }
        public void InsertOrUpdateSalesOrderHeaderStatusTest()
        {
            // Tested in DeleteSalesOrderStatuTest, but additional tests here
            var testUser = GetTestUser();

            var testSalesOrderStatu1 = createSalesOrderHeaderStatus();
            var error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindSalesOrderHeaderStatus(testSalesOrderStatu1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testSalesOrderStatu1, testModel);

            var testSalesOrderStatu2 = createSalesOrderHeaderStatus();

            error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindSalesOrderHeaderStatus(testSalesOrderStatu2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testSalesOrderStatu2, testModel);


            // Try to create a SalesOrderStatus with the same name
            var dupItem = LookupService.Clone(testSalesOrderStatu1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateSalesOrderHeaderStatus(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate SalesOrderStatus returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockSalesOrderHeaderStatus(testSalesOrderStatu1);

            testSalesOrderStatu1.StatusName = RandomString();
            testSalesOrderStatu1.StatusValue++;
            error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockSalesOrderHeaderStatus(testSalesOrderStatu1);

            testSalesOrderStatu1.StatusName  = testSalesOrderStatu2.StatusName;
            testSalesOrderStatu1.StatusValue = testSalesOrderStatu2.StatusValue;
            error = LookupService.InsertOrUpdateSalesOrderHeaderStatus(testSalesOrderStatu1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a SalesOrderStatus to the same name as an existing SalesOrderStatus returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 4
0
        public void InsertOrUpdateSupplierTermTest()
        {
            // Tested in SupplierTermTest, but additional tests here
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var testSupplierTerm1 = createSupplierTerm(testCompany);
            var error             = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindSupplierTerm(testSupplierTerm1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testSupplierTerm1, testModel);

            var testSupplierTerm2 = createSupplierTerm(testCompany);

            error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindSupplierTerm(testSupplierTerm2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testSupplierTerm2, testModel);


            // Try to create a SupplierTerm with the same name
            var dupItem = LookupService.Clone(testSupplierTerm1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateSupplierTerm(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate SupplierTerm returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockSupplierTerm(testSupplierTerm1);

            testSupplierTerm1.SupplierTermName = RandomString();
            error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockSupplierTerm(testSupplierTerm1);

            testSupplierTerm1.SupplierTermName = testSupplierTerm2.SupplierTermName;
            error = LookupService.InsertOrUpdateSupplierTerm(testSupplierTerm1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a SupplierTerm to the same name as an existing SupplierTerm returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 5
0
        public void InsertOrUpdateFreightCarrierTest()
        {
            // Tested in DeleteFreightCarrierTest, but additional tests here
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var testFreightCarrier1 = createFreightCarrier(testCompany);
            var error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindFreightCarrier(testFreightCarrier1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testFreightCarrier1, testModel);

            var testFreightCarrier2 = createFreightCarrier(testCompany);

            error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindFreightCarrier(testFreightCarrier2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testFreightCarrier2, testModel);


            // Try to create a FreightCarrier with the same name
            var dupItem = LookupService.Clone(testFreightCarrier1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateFreightCarrier(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate Freight Carrier returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockFreightCarrier(testFreightCarrier1);

            testFreightCarrier1.FreightCarrier = RandomString();
            error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockFreightCarrier(testFreightCarrier1);

            testFreightCarrier1.FreightCarrier = testFreightCarrier2.FreightCarrier;
            error = LookupService.InsertOrUpdateFreightCarrier(testFreightCarrier1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a Freight Carrier to the same name as an existing Freight Carrier returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 6
0
        public void InsertOrUpdatePriceLevelTest()
        {
            // Tested in DeletePriceLevelTest, but additional tests here
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var testPriceLevel1 = createPriceLevel(testCompany);
            var error           = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindPriceLevel(testPriceLevel1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testPriceLevel1, testModel);

            var testPriceLevel2 = createPriceLevel(testCompany);

            error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindPriceLevel(testPriceLevel2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testPriceLevel2, testModel);


            // Try to create a PriceLevel with the same name
            var dupItem = LookupService.Clone(testPriceLevel1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdatePriceLevel(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate PriceLevel returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockPriceLevel(testPriceLevel1);

            testPriceLevel1.Mneumonic = RandomString().Left(3);
            error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockPriceLevel(testPriceLevel1);

            testPriceLevel1.Mneumonic = testPriceLevel2.Mneumonic;
            error = LookupService.InsertOrUpdatePriceLevel(testPriceLevel1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a PriceLevel to the same name as an existing PriceLevel returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 7
0
        public void InsertOrUpdateMarketingGroupTest()
        {
            // Tested in DeleteMarketingGroupTest, but additional tests here
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var testMarketingGroup1 = createMarketingGroup(testCompany);
            var error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindMarketingGroup(testMarketingGroup1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testMarketingGroup1, testModel);

            var testMarketingGroup2 = createMarketingGroup(testCompany);

            error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindMarketingGroup(testMarketingGroup2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testMarketingGroup2, testModel);


            // Try to create a MarketingGroup with the same name
            var dupItem = LookupService.Clone(testMarketingGroup1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateMarketingGroup(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate MarketingGroup returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockMarketingGroup(testMarketingGroup1);

            testMarketingGroup1.MarketingGroupName = RandomString().Left(30);
            error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockMarketingGroup(testMarketingGroup1);

            testMarketingGroup1.MarketingGroupName = testMarketingGroup2.MarketingGroupName;
            error = LookupService.InsertOrUpdateMarketingGroup(testMarketingGroup1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a MarketingGroup Id to the same name as an existing MarketingGroup returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 8
0
        public void InsertOrUpdateLocationTest()
        {
            // Tested in DeleteLocationTest, but additional tests here
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser);

            var testLocation1 = createLocation(testCompany);
            var error         = LookupService.InsertOrUpdateLocation(testLocation1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindLocation(testLocation1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testLocation1, testModel);

            var testLocation2 = createLocation(testCompany);

            error = LookupService.InsertOrUpdateLocation(testLocation2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindLocation(testLocation2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testLocation2, testModel);


            // Try to create a Location with the same name
            var dupItem = LookupService.Clone(testLocation1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdateLocation(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate Location Id returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockLocation(testLocation1);

            testLocation1.LocationIdentification = RandomString().Left(10);
            error = LookupService.InsertOrUpdateLocation(testLocation1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockLocation(testLocation1);

            testLocation1.LocationIdentification = testLocation2.LocationIdentification;
            error = LookupService.InsertOrUpdateLocation(testLocation1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a Location Id to the same name as an existing Locatoin returned no error when it should have returned a 'duplicate' error");
        }
Ejemplo n.º 9
0
        public void InsertOrUpdatePortTest()
        {
            // Tested in DeletePortTest, but additional tests here
            var testUser = GetTestUser();

            var testPort1 = createPort();
            var error     = LookupService.InsertOrUpdatePort(testPort1, testUser, "");

            Assert.IsTrue(!error.IsError, error.Message);

            var test = db.FindPort(testPort1.Id);

            var testModel = LookupService.MapToModel(test);

            AreEqual(testPort1, testModel);

            var testPort2 = createPort();

            error = LookupService.InsertOrUpdatePort(testPort2, testUser, "");
            Assert.IsTrue(!error.IsError, error.Message);

            test = db.FindPort(testPort2.Id);

            testModel = LookupService.MapToModel(test);

            AreEqual(testPort2, testModel);


            // Try to create a Port with the same name
            var dupItem = LookupService.Clone(testPort1);

            dupItem.Id = 0;
            error      = LookupService.InsertOrUpdatePort(dupItem, testUser, "");
            Assert.IsTrue(error.IsError, "Error: Creating a duplicate Port returned no error when it should have returned a 'duplicate' error");

            // Try to rename the item to a non-existing name (should work)
            string lgs = LookupService.LockPort(testPort1);

            testPort1.PortName = RandomString().Left(30);
            error = LookupService.InsertOrUpdatePort(testPort1, testUser, lgs);
            Assert.IsTrue(!error.IsError, error.Message);

            // Try to rename to an existing item (should fail)
            lgs = LookupService.LockPort(testPort1);

            testPort1.PortName = testPort2.PortName;
            error = LookupService.InsertOrUpdatePort(testPort1, testUser, lgs);
            Assert.IsTrue(error.IsError, "Error: Renaming a Port to the same name as an existing Port returned no error when it should have returned a 'duplicate' error");
        }