public void FindPurchaseOrderHeaderByPONumberModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a record
            var poh1 = GetTestPurchaseOrderHeader(testCompany, testUser, 1);

            // Try to find it using the PONumber
            var poh2 = PurchasingService.FindPurchaseOrderHeaderByPONumberModel(poh1.OrderNumber.Value, testCompany);

            Assert.IsTrue(poh2 != null, "Error: A non-NULL value was expected");

            // Check thiat it is the same record
            decimal expected = poh1.OrderNumber.Value,
                    actual   = poh2.OrderNumber.Value;

            Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected");

            expected = poh1.Id;
            actual   = poh2.Id;
            Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected");

            PurchasingService.DeletePurchaseOrderHeader(poh1.Id);

            // Now try to find it again
            poh2 = PurchasingService.FindPurchaseOrderHeaderByPONumberModel(poh1.OrderNumber.Value, testCompany);
            Assert.IsTrue(poh2 == null, "Error: A NULL value was expected but an object was returned");
        }
Example #2
0
        public void FindPurchaseOrderHeaderSummaryListModelTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a random number of purchases
            List <PurchaseOrderHeaderModel> pohList = new List <PurchaseOrderHeaderModel>();
            int numPohs = RandomInt(5, 25);

            for (int i = 0; i < numPohs; i++)
            {
                pohList.Add(GetTestPurchaseOrderHeader(testCompany, testUser, 10));
            }

            // Check that they are found
            var result   = PurchasingService.FindPurchaseOrderHeaderSummaryListModel(testCompany, testUser, 0, 1, PageSize, "");
            int actual   = result.Items.Count;
            int expected = numPohs;

            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");

            // Now delete them
            foreach (var poh in pohList)
            {
                PurchasingService.DeletePurchaseOrderHeader(poh);
            }

            // Now check that they have disappeared
            result   = PurchasingService.FindPurchaseOrderHeadersListModel(testCompany.Id, 0, 1, PageSize, "", 0, 0, 0);
            actual   = result.Items.Count;
            expected = 0;
            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");
        }
Example #3
0
        public void FindPurchaseOrderHeadersStringTest()
        {
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a random number of purchases
            List <PurchaseOrderHeaderModel> pohList = new List <PurchaseOrderHeaderModel>();
            int numPohs = RandomInt(5, 15);

            for (int i = 0; i < numPohs; i++)
            {
                pohList.Add(GetTestPurchaseOrderHeader(testCompany, testUser, 10));
            }

            // Check that they are found
            var result   = PurchasingService.FindPurchaseOrderHeadersString(testCompany);
            int actual   = result.CountOf("|") + 1;
            int expected = numPohs;

            Assert.IsTrue(actual == expected, $"Error: {actual} items were returned when {expected} were expected");

            // Now delete them
            foreach (var poh in pohList)
            {
                PurchasingService.DeletePurchaseOrderHeader(poh);
            }

            // Now check that they have disappeared
            result = PurchasingService.FindPurchaseOrderHeadersString(testCompany);
            Assert.IsTrue(result == "", $"Error: '{result}' was returned when and empty string was expected");
        }
Example #4
0
        public void DeletePurchaseOrderHeaderTest()
        {
            // Get a test user
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a purchase
            var model = GetTestPurchaseOrderHeader(testCompany, testUser, 10);

            // Check that it was written
            var result = db.FindPurchaseOrderHeader(model.Id);
            var test   = PurchasingService.MapToModel(result);

            var excludes = new List <string>();

            excludes.Add("OrderNumberUrl");         // Because it isn't known yet
            AreEqual(model, test, excludes);

            // Now delete it
            PurchasingService.DeletePurchaseOrderHeader(model.Id);

            // And check that is was deleted
            result = db.FindPurchaseOrderHeader(model.Id);
            Assert.IsTrue(result == null, "Error: A non-NULL value was returned when a NULL value was expected - record delete failed");
        }
Example #5
0
        public void GetPurchaseCountTest()
        {
            // Get a test user and test company
            var testUser    = GetTestUser();
            var testCompany = GetTestCompany(testUser, true);

            // Create a purchase
            int actual   = PurchasingService.GetPurchaseCount(testCompany);
            int expected = 0;

            Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected");

            var testPurchase = GetTestPurchaseOrderHeader(testCompany, testUser);

            actual   = PurchasingService.GetPurchaseCount(testCompany);
            expected = 1;
            Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected");

            PurchasingService.DeletePurchaseOrderHeader(testPurchase.Id);
            actual   = PurchasingService.GetPurchaseCount(testCompany);
            expected = 0;
            Assert.IsTrue(expected == actual, $"Error: {actual} was returned when {expected} was expected");
        }