<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<!--
Copyright 2004 ThoughtWorks, Inc

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Assert tests</title>
<script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script>
<script language="JavaScript" type="text/javascript" src="../jsmock/mock.js"></script>
<script language="JavaScript" type="text/javascript" src="../dummy-logging.js"></script>

<script language="JavaScript" type="text/javascript" src="../../core/scripts/htmlutils.js"></script>
<script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-executionloop.js"></script>
<script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-api.js"></script>
<script language="JavaScript" type="text/javascript">

function testAssertEqalsDoesntThrowExceptionWhenMatches() {
	Assert.equals("foo", "foo");
}

function testAssertEqualsThrowsExceptionWhenNotMatches() {
	try {
		Assert.equals("foo", "fox");
	}
	catch (e) {		
		assertEquals("Expected 'foo' but was 'fox'", e.failureMessage);
		return;
	}
	fail("Should have thrown exception");
}

function testAssertEqualsCanIncludeAComment() {
	try {
		Assert.equals("testComment", "foo", "fox");
	}
	catch (e) {		
		assertEquals("testComment; Expected 'foo' but was 'fox'", e.failureMessage);
		return;
	}
	fail("Should have thrown exception");
}

function testAssertMatchesDoesntThrowExceptionWhenMatches() {
	Assert.matches("regexp:fo[aeiou]", "foo");
}

function testAssertMatchesThrowsExceptionWhenNotMatches() {
	try {
		Assert.matches("regexp:fo[aei]", "foo");
	}
	catch (e) {		
		assertEquals("Actual value 'foo' did not match 'regexp:fo[aei]'", e.failureMessage);
		return;
	}
	fail("Should have thrown exception");
}

function testPatternMatchesCanIncludeComment() {
	try {
		Assert.matches("TestComment", "regexp:fo[aei]", "foo");
		assertEquals("TestComment; Actual value 'foo' did not match 'regexp:fo[aei]'", e.failureMessage);
	}
	catch (e) {
		return;
	}
	fail("Should have thrown exception");
}

function testAssertNotMatchesDoesntThrowExceptionWhenNotMatches() {
	Assert.notMatches("regexp:fo[aeiou]", "fox");
}

function testAssertNotMatchesThrowsExceptionWhenMatches() {
	try {
		Assert.notMatches("regexp:fo[aeix]", "fox");
	}
	catch (e) {
		assertEquals("Actual value 'fox' did match 'regexp:fo[aeix]'", e.failureMessage);
		return;
	}
	fail("Should have thrown exception");
}

function testAssertNotMatchesCanIncludeComment() {
	try {
		Assert.notMatches("TestComment", "regexp:fo[aeix]", "fox");
	}
	catch (e) {
		assertEquals("TestComment; Actual value 'fox' did match 'regexp:fo[aeix]'", e.failureMessage);
		return;
	}
	fail("Should have thrown exception");
}

</script>
  </head>
  <body>Assert Tests</body>
</html>s