Пример #1
0
        public void isRouteNameInvalid_InvalidRouteName_ErrorReturnedRouteNotCreated(string routeName)
        {
            DateTime regionNextDate = dateCalculation.GetOneDate(rOne);

            Route routeOne = new Route()
            {
                routeName = routeName,
                regionID  = rOne.regionID,
                region    = rOne,
                completed = false,
                routeDate = regionNextDate
            };

            List <ValidationResult> results = ClassValidator <Route> .Validate(routeOne);

            Assert.Single(results);

            switch (routeOne.routeName.Length)
            {
            case 0:
                Assert.Equal("Route Name cannot be empty", results[0].ToString());
                break;

            case int n when n > 0 && n < 2:
                Assert.Equal("Route Name must be at least 2 characters", results[0].ToString());
                break;

            case int n when n > 40:
                Assert.Equal("Route Name cannot be greater than 40 characters", results[0].ToString());
                break;
            }
        }
Пример #2
0
        public void isRegionRequired_NoRegionSet_ErrorReturnedRouteNotCreated()
        {
            Route routeOne = new Route()
            {
                routeName = "Harbor Creek",
                completed = false,
                routeDate = new DateTime(2021, 01, 01)
            };

            List <ValidationResult> results = ClassValidator <Route> .Validate(routeOne);

            Assert.Single(results);
            Assert.Equal("Route must have a Region", results[0].ToString());
        }
Пример #3
0
        public void isValidRegionCreated_ValidRegionSet_RouteIsCreated()
        {
            Route routeOne = new Route()
            {
                routeName = "Harbor Creek",
                regionID  = 5,
                region    = new Region(),
                completed = false,
                routeDate = new DateTime(2021, 01, 01)
            };

            List <ValidationResult> results = ClassValidator <Route> .Validate(routeOne);

            Assert.Empty(results);
        }
Пример #4
0
        public void isValidRouteCreated_ValidRoute_RouteCreated()
        {
            DateTime date = DateTime.Now;

            Route routeOne = new Route()
            {
                routeName = "Harbor Creek",
                regionID  = rOne.regionID,
                region    = rOne,
                completed = false,
                routeDate = new DateTime(date.Year + 1, date.Month, date.Day)
            };

            List <ValidationResult> results = ClassValidator <Route> .Validate(routeOne);

            Assert.Empty(results);
        }
Пример #5
0
        public void isRouteNameValid_ValidRouteName_RouteIsCreated(string routeName)
        {
            DateTime date = DateTime.Today;

            Route routeOne = new Route()
            {
                routeName = routeName,
                regionID  = rOne.regionID,
                region    = rOne,
                completed = false,
                routeDate = new DateTime(date.Year + 1, date.Month, date.Day)
            };

            List <ValidationResult> results = ClassValidator <Route> .Validate(routeOne);

            Assert.Empty(results);
        }