GetData() public method

public GetData ( ) : object
return object
コード例 #1
0
ファイル: ContentTest.cs プロジェクト: maxpavlov/FlexNet
		public void Content_FieldControl()
		{
			Node automobileNode = LoadOrCreateAutomobileAndSave(AutomobileHandler.ExtendedCTD, "Automobile12", "Honda", "Gyeby");
			SNC.Content automobileContent = SNC.Content.Create(automobileNode);
			Field manuField = automobileContent.Fields["Manufacturer"];
			Field drivField = automobileContent.Fields["Driver"];

			ShortText shortText = new ShortText();
			ShortTextAccessor shortTextAcc = new ShortTextAccessor(shortText);
			ShortText shortTextEditor = new ShortText();
			ShortTextAccessor shortTextEditorAcc = new ShortTextAccessor(shortTextEditor);

			//-- contentview szimulacio: RegisterFieldControl
			shortTextAcc.ConnectToField(manuField);
			shortTextEditorAcc.ConnectToField(drivField);

			Assert.IsTrue(shortTextAcc.Text == (string)automobileContent["Manufacturer"], "#01");
			Assert.IsTrue(shortTextEditorAcc.InputTextBox.Text == (string)automobileContent["Driver"], "#02");

			shortTextEditorAcc.InputTextBox.Text = "Netudki";

			//-- contentview szimulacio: PostData
			drivField.SetData(shortTextEditor.GetData());

			// automobileContent.IsValid?

			string result = (string)automobileContent["Driver"];
			Assert.IsTrue(result == "Netudki", "#03");
		}
コード例 #2
0
ファイル: EvaluatorTest.cs プロジェクト: maxpavlov/FlexNet
		public void DefaultValue_Scripted_ShortText()
		{
			ContentType carType = ContentType.GetByName("Car");
			string defaultValue = "The answer to life the universe and everything plus one = [Script:jScript]WhatIsTheAnswerToLifeTheUniverseAndEverything() + 1;[/Script].";
			string evaluatedValue = "The answer to life the universe and everything plus one = 43.";
			string userInput = "-- UserInput --";
			string fieldName = null;
			string fieldValue = null;

			//==== search a testable ShortText field
			foreach (var fieldSetting in carType.FieldSettings)
			{
				ShortTextFieldSetting shortTextSetting = fieldSetting as ShortTextFieldSetting;
				if (shortTextSetting == null)
					continue;
				fieldName = shortTextSetting.Name;
				var baseSettingAccessor = new PrivateObject(shortTextSetting, new PrivateType(typeof(FieldSetting)));
				baseSettingAccessor.SetField("_defaultValue", BindingFlags.NonPublic | BindingFlags.Instance, defaultValue);
				break;
			}
			if (fieldName == null)
				Assert.Inconclusive("Car ContentType do not have any ShortText field.");

			//==== create a new Content
			var newContent = Content.CreateNew("Car", _testRoot, "Car1");
			var editedField = newContent.Fields[fieldName];

			//==== simulating contentview:
			//-- create control RegisterFieldControl, SetData, Post default value
			ShortText shortTextControl = new ShortText();
			ShortTextAccessor shortTextControlAcc = new ShortTextAccessor(shortTextControl);
			//-- RegisterFieldControl, SetData, Post default value
			shortTextControlAcc.ConnectToField(editedField);
			shortTextControlAcc.SetDataInternal();
			//-- Post default value
			editedField.SetData(shortTextControl.GetData());

			//==== Check default value
			fieldValue = (string)newContent[fieldName];
			Assert.IsTrue(fieldValue == evaluatedValue, "#1");

			//-- simulating userinput: overwrite default value
			shortTextControlAcc.InputTextBox.Text = userInput;

			//-- simulating contentview: PostData
			editedField.SetData(shortTextControl.GetData());

			//==== Check user input
			fieldValue = (string)newContent[fieldName];
			Assert.IsTrue(fieldValue == userInput, "#2");

		}