Exemplo n.º 1
0
		public void TestCRUD()
		{
			m1 = new Member( list.Id, "John Doe", "*****@*****.**" );
			// insert
			m1.Persist();
			Assert.AreEqual( m1.Name, "John Doe", "The object was not properly inserted!" );
			Assert.AreEqual( m1.Address, "*****@*****.**", "The object was not properly inserted!" );
			// select
			m2 = Member.Retrieve( m1.Id );
			// verify select/insert
			Assert.IsTrue( m2.Id != 0, "The object could not be retrieved from the database!" );
			Assert.AreEqual( m1.Id, m2.Id, "The object could not be retrieved from the database!" );
			Assert.AreEqual( "John Doe", m2.Name, "The object was not properly retrieved on construction!" );
			Assert.AreEqual( "*****@*****.**", m2.Address,
			                 "The object was not properly retrieved on construction!" );
			// update
			m2.Name = "Jane Doe";
			m2.Address = "*****@*****.**";
			m2.Persist();
			// verify update
			m1 = Member.Retrieve( m2.Id );
			Assert.AreEqual( m2.Name, m1.Name, "Name not updated!" );
			Assert.AreEqual( m2.Address, m1.Address, "SenderAddress not updated!" );
			// delete
			m2.Remove();
			// verify delete by counting the number of rows
			SqlBuilder sb = new SqlBuilder( StatementType.Count, typeof(Member) );
			sb.AddConstraint( Operator.Equals, "Id", m1.Id );
			SqlResult sr = Broker.Execute( sb.GetStatement( true ) );
			Assert.AreEqual( 0, sr.Count, "Object not removed" );
		}
Exemplo n.º 2
0
 public void TestRegexBad()
 {
     // test that a `bad` email address throws an exception
     m1 = new Member(list.Id, "John Doe", "john-doe.com");
     // insert
     m1.Persist();
 }
Exemplo n.º 3
0
		public void TestRegexBad()
		{
			// test that a `bad` email address throws an exception
			m1 = new Member( list.Id, "John Doe", "john-doe.com" );
			// insert
			m1.Persist();
		}
Exemplo n.º 4
0
 public void TestRequiredBad()
 {
     // test that an empty email address throws an exception
     m1 = new Member(list.Id, string.Empty, "*****@*****.**");
     // insert
     m1.Persist();
 }
Exemplo n.º 5
0
        public void TestCRUD()
        {
            m1 = new Member(list.Id, "John Doe", "*****@*****.**");
            // insert
            m1.Persist();
            Assert.AreEqual(m1.Name, "John Doe", "The object was not properly inserted!");
            Assert.AreEqual(m1.Address, "*****@*****.**", "The object was not properly inserted!");
            // select
            m2 = Member.Retrieve(m1.Id);
            // verify select/insert
            Assert.IsTrue(m2.Id != 0, "The object could not be retrieved from the database!");
            Assert.AreEqual(m1.Id, m2.Id, "The object could not be retrieved from the database!");
            Assert.AreEqual("John Doe", m2.Name, "The object was not properly retrieved on construction!");
            Assert.AreEqual("*****@*****.**", m2.Address,
                            "The object was not properly retrieved on construction!");
            // update
            m2.Name    = "Jane Doe";
            m2.Address = "*****@*****.**";
            m2.Persist();
            // verify update
            m1 = Member.Retrieve(m2.Id);
            Assert.AreEqual(m2.Name, m1.Name, "Name not updated!");
            Assert.AreEqual(m2.Address, m1.Address, "SenderAddress not updated!");
            // delete
            m2.Remove();
            // verify delete by counting the number of rows
            SqlBuilder sb = new SqlBuilder(StatementType.Count, typeof(Member));

            sb.AddConstraint(Operator.Equals, "Id", m1.Id);
            SqlResult sr = Broker.Execute(sb.GetStatement(true));

            Assert.AreEqual(0, sr.Count, "Object not removed");
        }
Exemplo n.º 6
0
 public void TestDateRangeGood()
 {
     m1 = new MemberValidation(0, 1, "John Doe", "*****@*****.**");
     // insert - no exception because default dates are inside valid range
     m1.Persist();
     // clean up
     m1.Remove();
 }
Exemplo n.º 7
0
 public void TestRequiredBadButAllowNull()
 {
     // test that an empty email address throws an exception
     m1 = new Member(list.Id, null, "*****@*****.**");
     // insert
     m1.Persist();
     // delete
     m1.Remove();
 }
Exemplo n.º 8
0
 public void CustomValidatorGood()
 {
     // no exception because listid > id
     m1 = new MemberValidation(0, 1, "John Doe", "*****@*****.**");
     // insert
     m1.Persist();
     // clean up
     m1.Remove();
 }
Exemplo n.º 9
0
 public void CustomValidatorBad()
 {
     // exception because listid < id
     m1 = new MemberValidation(1, 0, "John Doe", "*****@*****.**");
     // insert
     m1.Persist();
     // clean up (not executed unless Persist erroneously succeeds)
     m1.Remove();
 }
Exemplo n.º 10
0
		public void TestRegexGoodData()
		{
			// test that a `good` email address can be entered in the database
			m1 = new Member( list.Id, "John Doe", "*****@*****.**" );
			// insert
			m1.Persist();
			Assert.AreEqual( m1.Name, "John Doe", "The object was not properly inserted!" );
			Assert.AreEqual( m1.Address, "*****@*****.**", "The object was not properly inserted!" );
			// delete
			m1.Remove();
		}
Exemplo n.º 11
0
 public void TestRequiredGood()
 {
     // test that an email address (required field) entered passes validation
     m1 = new Member(list.Id, "John Doe", "*****@*****.**");
     // insert
     m1.Persist();
     Assert.AreEqual(m1.Name, "John Doe", "The object was not properly inserted!");
     Assert.AreEqual(m1.Address, "*****@*****.**", "The object was not properly inserted!");
     // delete
     m1.Remove();
 }
Exemplo n.º 12
0
 public void TestRegexGoodData()
 {
     // test that a `good` email address can be entered in the database
     m1 = new Member(list.Id, "John Doe", "*****@*****.**");
     // insert
     m1.Persist();
     Assert.AreEqual(m1.Name, "John Doe", "The object was not properly inserted!");
     Assert.AreEqual(m1.Address, "*****@*****.**", "The object was not properly inserted!");
     // delete
     m1.Remove();
 }
Exemplo n.º 13
0
		public void TestRequiredGood()
		{
			// test that an email address (required field) entered passes validation
			m1 = new Member( list.Id, "John Doe", "*****@*****.**" );
			// insert
			m1.Persist();
			Assert.AreEqual( m1.Name, "John Doe", "The object was not properly inserted!" );
			Assert.AreEqual( m1.Address, "*****@*****.**", "The object was not properly inserted!" );
			// delete
			m1.Remove();
		}
Exemplo n.º 14
0
		public void TestRequiredBad()
		{
			// test that an empty email address throws an exception
			m1 = new Member( list.Id, string.Empty, "*****@*****.**" );
			// insert
			m1.Persist();
		}
Exemplo n.º 15
0
		public void TestRequiredBadButAllowNull()
		{
			// test that an empty email address throws an exception
			m1 = new Member( list.Id, null, "*****@*****.**" );
			// insert
			m1.Persist();
			// delete
			m1.Remove();
		}
Exemplo n.º 16
0
		public void TestDateRangeGood()
		{
			m1 = new MemberValidation( 0, 1, "John Doe", "*****@*****.**" );
			// insert - no exception because default dates are inside valid range
			m1.Persist();
			// clean up
			m1.Remove();
		}
Exemplo n.º 17
0
		public void CustomValidatorGood()
		{
			// no exception because listid > id
			m1 = new MemberValidation( 0, 1, "John Doe", "*****@*****.**" );
			// insert
			m1.Persist();
			// clean up
			m1.Remove();
		}
Exemplo n.º 18
0
		public void CustomValidatorBad()
		{
			// exception because listid < id
			m1 = new MemberValidation( 1, 0, "John Doe", "*****@*****.**" );
			// insert
			m1.Persist();
			// clean up (not executed unless Persist erroneously succeeds)
			m1.Remove();
		}