コード例 #1
0
        //testing that the siteID of a Site object of 1 is valid
        public void TestThatSiteIDOfOneIsValid()
        {
            testSite.siteID = 1;
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }
コード例 #2
0
        public void TestThatSiteFrequencyOfBiWeeklyIsValid()
        {
            testSite.frequency = Site.PickupFrequency.BiWeekly;
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }
コード例 #3
0
        //testing that the address of a Site object can be 1 character
        public void TestThatSiteAddressOfOneCharacterIsValid()
        {
            testSite.address = "a";
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }
コード例 #4
0
        //testing that the address of a Site object can be 200 characters
        public void TestThatSiteAddressOf200CharactersIsValid()
        {
            testSite.address = new string('a', 200);
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }
コード例 #5
0
        //Test that a Site object with an "empty" frequency is not valid
        public void TestThatSiteFrequencyOfZeroIsInvalid()
        {
            testSite.frequency = 0;
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[0].ErrorMessage);
        }
コード例 #6
0
        public void TestThatCollectionDayOfWeekMondayToFridayIsValid()
        {
            testSite.sitePickupDays = Site.PickupDays.Monday | Site.PickupDays.Tuesday | Site.PickupDays.Wednesday | Site.PickupDays.Thursday | Site.PickupDays.Friday;

            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }
コード例 #7
0
        public void TestThatValidSiteObjectIsCreatedWithValidSiteInformation()
        {
            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(0, results.Count);
        }
コード例 #8
0
        //testing that the address of a Site object cannot be an empty string
        public void TestThatSiteAddressOfEmptyStringIsInvalid()
        {
            testSite.address = "";
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Address must be 1 to 200 characters", results[0].ErrorMessage);
        }
コード例 #9
0
        //testing that siteID cannot be 0
        public void TestThatSideIDOfZeroIsInvalid()
        {
            testSite.siteID = 0;
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("The siteID must be a valid integer", results[0].ErrorMessage);
        }
コード例 #10
0
        public void TestThatInvalidDayOfWeekFailsValidation(Site.PickupDays day)
        {
            testSite.sitePickupDays = day;
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Specified Pickup Days are invalid", results[0].ErrorMessage);
        }
コード例 #11
0
        public void TestThatSiteObjectWithAddressOf200PassesValidation()
        {
            // Address field
            cellList[7] = new string('a', 200);

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(0, results.Count);
        }
コード例 #12
0
        public void TestThatSiteObjectWithAddressOf201FailsValidation()
        {
            // Address field
            cellList[7] = new string('a', 201);

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Address must be 1 to 200 characters", results[0].ErrorMessage);
        }
コード例 #13
0
        public void TestThatSiteObjectWithPickupDayOfInvalidFailsValidation()
        {
            // PickupDay field
            cellList[15] = "sdfafa";

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Specified Pickup Days are invalid", results[0].ErrorMessage);
        }
コード例 #14
0
        public void TestThatSiteObjectWithFrequencyOfInvalidFailsValidation()
        {
            // Frequency field
            cellList[10] = "sdfafa";

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(1, results.Count);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[0].ErrorMessage);
        }
コード例 #15
0
        public void TestThatTooFewColumnsInExcelSheetReturnsASiteObjectWithIDOfNegativeTwo()
        {
            cellList.Remove(cellList[5]);
            cellList.Remove(cellList[6]);

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, true);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(3, results.Count);
            Assert.AreEqual("The siteID must be a valid integer", results[0].ErrorMessage);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[1].ErrorMessage);
            Assert.AreEqual("Specified Pickup Days are invalid", results[2].ErrorMessage);
        }
コード例 #16
0
        public void TestThatTooManyColumnsInExcelSheetReturnsASiteObjectWithIDOfNegativeTwo()
        {
            // Adding an extra column (which is 1 too many)
            cellList.Add("Sdawdawdawdaw");

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, true);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(3, results.Count);
            Assert.AreEqual("The siteID must be a valid integer", results[0].ErrorMessage);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[1].ErrorMessage);
            Assert.AreEqual("Specified Pickup Days are invalid", results[2].ErrorMessage);
        }
コード例 #17
0
        public void TestThatHeaderRowWithValidDataReturnsASiteObjectWithSiteIDOf1()
        {
            cellList[1]  = "Site ID";
            cellList[7]  = "Full Address";
            cellList[10] = "Frequency";
            cellList[15] = "Collection1";
            cellList[16] = "Collection2";
            cellList[17] = "Collection3";
            cellList[18] = "Collection4";

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, true);

            Assert.AreEqual(1, site.siteID);
            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(0, results.Count);
        }
コード例 #18
0
        public void TestThatHeaderRowWithInValidDataReturnsAnInvalidSiteObject()
        {
            cellList[1]  = "Site ID";
            cellList[7]  = "Full Address";
            cellList[10] = "Frequency";
            cellList[15] = "Colleasdasction1";
            cellList[16] = "Collection2";
            cellList[17] = "Collection3";
            cellList[18] = "Collection4";

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, true);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(3, results.Count);
            Assert.AreEqual("The siteID must be a valid integer", results[0].ErrorMessage);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[1].ErrorMessage);
            Assert.AreEqual("Specified Pickup Days are invalid", results[2].ErrorMessage);
        }
コード例 #19
0
        public void TestThatInvalidSiteObjectIsCreatedWithInvalidSiteInformation()
        {
            // Site ID
            cellList[1] = "jdasdfa";
            // Address
            cellList[7] = "";
            // Frequency
            cellList[10] = "jdfsal";
            // Collection1
            cellList[15] = "23kjl32";

            Site site = SiteParser.GenerateSiteObjectFromRow(cellList, false);

            var results = HelperTestModel.Validate(site);

            Assert.AreEqual(4, results.Count);

            Assert.AreEqual("The siteID must be a valid integer", results[0].ErrorMessage);
            Assert.AreEqual("Address must be 1 to 200 characters", results[1].ErrorMessage);
            Assert.AreEqual("Pickup Frequency must be Weekly or BiWeekly", results[2].ErrorMessage);
            Assert.AreEqual("Specified Pickup Days are invalid", results[3].ErrorMessage);
        }
コード例 #20
0
        //testing that the valid Site object is indeed valid
        public void TestThatValidSiteIsValid()
        {
            var results = HelperTestModel.Validate(testSite);

            Assert.AreEqual(0, results.Count);
        }