Exemplo n.º 1
0
        public void ServiceLayer_CleanUpDates()
        {
            // Insert a listener with a invalid dates
            int      listenerId = 332;
            Listener l2         = new Listener()
            {
                Title = "Miss", Forename = "Clean", Surname = "Dates", Addr1 = "40 Clean Road", Addr2 = "", County = "London", Postcode = "N7 8AB", Town = "Camden", Telephone = "07843434343", Stock = 3, Info = "", Joined = DateTime.Now, MemStickPlayer = false, Magazine = true, Status = ListenerStates.ACTIVE, StatusInfo = "", Wallet = listenerId, Birthday = DateTime.Parse("01/01/1000"), DeletedDate = DateTime.Parse("01/01/1000"), LastIn = DateTime.Parse("01/01/1000"), LastOut = DateTime.Parse("01/01/1000")
            };

            repoLayer.InsertListener(serviceLayer.GetConnection(), l2);

            // Get the listener.
            Listener retrieved = serviceLayer.GetListenerById(listenerId);

            // Check the dates are invalid!
            Assert.IsTrue(retrieved.Birthday.Value < DBUtils.AppMinDate());
            Assert.IsTrue(retrieved.DeletedDate.Value < DBUtils.AppMinDate());
            Assert.IsTrue(retrieved.LastOut.Value < DBUtils.AppMinDate());
            Assert.IsTrue(retrieved.LastIn.Value < DBUtils.AppMinDate());

            // Clean them up
            serviceLayer.CleanUpDates();

            // Get the updated listener.
            Listener updated = serviceLayer.GetListenerById(listenerId);

            // Check they are now valid
            Assert.IsFalse(updated.Birthday.HasValue);
            Assert.IsFalse(updated.DeletedDate.HasValue);
            Assert.IsFalse(updated.LastOut.HasValue);
            Assert.IsFalse(updated.LastIn.HasValue);
        }