コード例 #1
0
		public void CreateUser()
		{
			ie.GoTo("http://localhost:88/UserScaffold/new.castle");

			ie.Button(Find.ByValue("Create")).Click(); // Trying to save will spark the validation

			Assert.AreEqual("http://localhost:88/UserScaffold/new.castle", ie.Url);

			Assert.IsTrue(ie.Elements.Exists("advice-required-User_Name"));
			Assert.AreEqual("This is a required field.", ie.Element("advice-required-User_Name").InnerHtml);

			ie.TextField("User_Name").TypeText("John Doe");
			ie.SelectList("User_Account_Id").SelectByValue(account1.Id.ToString());

			ie.Button(Find.ByValue("Create")).Click(); // Now it should save

			Assert.AreEqual("http://localhost:88/UserScaffold/list.castle", ie.Url);

			IWatiNElementCollection elements = ie.Elements.Filter(Find.ByClass("idRow"));
		
			Assert.IsTrue(elements.Length > 0, "Newly added object not present on the list?");

			int id = Convert.ToInt32(elements[elements.Length - 1].InnerHtml);

			user = ActiveRecordMediator<User>.FindByPrimaryKey(id);

			Assert.AreEqual("John Doe", user.Name);
			Assert.IsNotNull(user.Account);
			Assert.AreEqual(account1.Id, user.Account.Id);
		}
コード例 #2
0
		protected override void CreateTestData()
		{
			lic1 = new ProductLicense();
			lic2 = new ProductLicense();

			perm1 = new AccountPermission("Permission 1");
			perm2 = new AccountPermission("Permission 2");

			user1 = new User("John Doe");
			user2 = new User("Mary Jane");

			ActiveRecordMediator<ProductLicense>.Create(lic1);
			ActiveRecordMediator<ProductLicense>.Create(lic2);
			ActiveRecordMediator<AccountPermission>.Create(perm1);
			ActiveRecordMediator<AccountPermission>.Create(perm2);
			ActiveRecordMediator<User>.Create(user1);
			ActiveRecordMediator<User>.Create(user2);
		}
コード例 #3
0
		public void EditUser()
		{
			CreateUser();

			ie.GoTo("http://localhost:88/UserScaffold/edit.castle?id=" + user.Id);

			ie.TextField("User_Name").TypeText("");
			ie.Button(new Value("Save Changes")).Click(); // Trying to save will spark the validation

			Assert.AreEqual("http://localhost:88/UserScaffold/edit.castle?id=" + user.Id, ie.Url);

			Assert.IsTrue(ie.Elements.Exists("advice-required-User_Name"));
			Assert.AreEqual("This is a required field.", ie.Element("advice-required-User_Name").InnerHtml);

			ie.TextField("User_Name").TypeText("Mary Jane");
			ie.SelectList("User_Account_Id").SelectByValue(account2.Id.ToString());

			ie.Button(new Value("Save Changes")).Click(); // Now it should save

			Assert.AreEqual("http://localhost:88/UserScaffold/list.castle", ie.Url);

			ElementCollection elements = ie.Elements.Filter(new Attribute("className", "idRow"));

			Assert.IsTrue(elements.Length > 0, "Changed object not present on the list?");

			int id = Convert.ToInt32(elements[elements.Length - 1].InnerHtml);

			user = ActiveRecordMediator<User>.FindByPrimaryKey(id);

			Assert.AreEqual("Mary Jane", user.Name);
			Assert.IsNotNull(user.Account);
			Assert.AreEqual(account2.Id, user.Account.Id);
		}