public void Import_WithBadPersonIds()
        {
            var attendancesImport = GetAttendancesImport();

            Assert.That.IsNotNull(attendancesImport);

            Exception exception = null;

            try
            {
                var random = new Random();
                attendancesImport.Attendances.ForEach(a =>
                {
                    var randomId = random.Next();
                    a.PersonId   = randomId;
                });
                AttendanceService.BulkAttendanceImport(attendancesImport);

                // if this doesn't fail, the test fails
                Assert.That.IsTrue(false);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // Test passes if we get a SqlException
            Assert.That.IsTrue(exception is SqlException, exception.Message);
        }
        public void Import_WithBothNullPersonIdAndNullPersonAliasId()
        {
            var attendancesImport = GetAttendancesImport();

            attendancesImport.Attendances.ForEach(a =>
            {
                a.PersonId      = null;
                a.PersonAliasId = null;
            });

            Assert.That.IsNotNull(attendancesImport);
            Exception exception = null;

            try
            {
                AttendanceService.BulkAttendanceImport(attendancesImport);

                // if this doesn't fail, the test fails
                Assert.That.IsTrue(false);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            // Test passes if we get a SqlException
            Assert.That.IsTrue(exception.Message == "All Attendance records must have either a PersonId or PersonAliasId assigned.", exception.Message);
        }
        public void AttendanceImport(Rock.BulkImport.AttendancesImport attendancesImport)
        {
            if (attendancesImport == null)
            {
                var response = new HttpResponseMessage
                {
                    StatusCode = HttpStatusCode.BadRequest,
                    Content    = new StringContent("AttendancesImport data is required")
                };

                throw new HttpResponseException(response);
            }

            AttendanceService.BulkAttendanceImport(attendancesImport);
        }
Example #4
0
        public void Import_WithBothPersonIdAndPersonAliasId()
        {
            var attendancesImport = GetAttendancesImport();

            Assert.IsNotNull(attendancesImport);

            try
            {
                AttendanceService.BulkAttendanceImport(attendancesImport);
                Assert.IsTrue(true);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }
        public void Import_WithPersonAliasId()
        {
            var attendancesImport = GetAttendancesImport();

            Assert.That.IsNotNull(attendancesImport);

            // don't include PersonId value
            attendancesImport.Attendances.ForEach(a => a.PersonId = null);

            try
            {
                AttendanceService.BulkAttendanceImport(attendancesImport);
                Assert.That.IsTrue(true);
            }
            catch (Exception ex)
            {
                Assert.That.Fail(ex.Message);
            }
        }