public void GoToPage(TestPageType pageType) { if (_currentPageType == pageType) { return; //we're already on the same page, so don't bother doing anything } TestTitlePage pageToCreate = null; if (pageType == TestPageType.TitlePage) { pageToCreate = new TestTitlePage(); } if (pageToCreate != null) //destroy the old page and create a new one { _currentPageType = pageType; if (_currentPage != null) { _stage.RemoveChild(_currentPage); } _currentPage = pageToCreate; _stage.AddChild(_currentPage); _currentPage.Start(); } }
public void GivenPageFromCreateAndPopulateTypedInstance_CompilerGeneratedPropertySetter_IsAutoImplemented() { TypedPageActivator activator = new TypedPageActivator(); TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(new PageData(), typeof(TestPageType)); page.Property.Add("CompilerGeneratedProperty", new PropertyString()); string propertyValue = TestValueUtility.CreateRandomString(); page.CompilerGeneratedProperty = propertyValue; Assert.Equal <string>(propertyValue, page["CompilerGeneratedProperty"] as string); }
public void GivenANullableDoublePropertyWithNullValue_WhenAccessedWithCompilerGeneratedPropertyGetter_ShouldReturnTheUnderlyingValue() { TypedPageActivator activator = new TypedPageActivator(); TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(new PageData(), typeof(TestPageType)); var property = new PropertyFloatNumber(); page.Property.Add("NullableDoubleTestProperty", property); double?returnedPropertyValue = page.NullableDoubleTestProperty; Assert.False(returnedPropertyValue.HasValue); }
public void GivenPageWithPropertyValue_CreateAndPopulateTypedInstance_ReturnsTypedInstanceWithPropertyValue() { PageData sourcePage = new PageData(); string propertyName = TestValueUtility.CreateRandomString(); sourcePage.Property.Add(propertyName, new PropertyString()); string propertyValue = TestValueUtility.CreateRandomString(); sourcePage.SetValue(propertyName, propertyValue); TypedPageActivator activator = new TypedPageActivator(); TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(sourcePage, typeof(TestPageType)); Assert.Equal <string>(propertyValue, page.GetValue(propertyName) as string); }
public void GivenANullableIntProperty_WhenAccessedWithCompilerGeneratedPropertyGetter_ShouldReturnTheUnderlyingValue() { TypedPageActivator activator = new TypedPageActivator(); TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(new PageData(), typeof(TestPageType)); var property = new PropertyNumber(); page.Property.Add("NullableIntTestProperty", property); int propertyValue = 123; page.SetValue("NullableIntTestProperty", propertyValue); int returnedPropertyValue = page.NullableIntTestProperty.Value; Assert.Equal <int>(propertyValue, returnedPropertyValue); }
public void GivenANullableDoubleProperty_WhenSetAndAccessedWithCompilerGeneratedPropertyGetter_ShouldReturnTheSetValue() { TypedPageActivator activator = new TypedPageActivator(); var originalPage = new PageData(); var property = new PropertyFloatNumber(); originalPage.Property.Add("NullableDoubleTestProperty", property); TestPageType page = (TestPageType)activator.CreateAndPopulateTypedInstance(originalPage, typeof(TestPageType)); double propertyValue = 123.45; page.NullableDoubleTestProperty = propertyValue; double returnedPropertyValue = page.NullableDoubleTestProperty.Value; Assert.Equal <double>(propertyValue, returnedPropertyValue); }