コード例 #1
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
 public void PropertiesAreActuallyRegisteredWithDefaultValues()
 {
     var instance = new ClassWithPropertiesRegisteredByNonMagicStringOverload();
     Assert.AreEqual(ClassWithPropertiesRegisteredByNonMagicStringOverload.StringPropertyWithSpecifiedDefaultValueProperty.GetDefaultValue<string>(), instance.StringPropertyWithSpecifiedDefaultValue);
     Assert.AreEqual(ClassWithPropertiesRegisteredByNonMagicStringOverload.StringPropertyProperty.GetDefaultValue<string>(), instance.StringProperty);
     Assert.AreEqual(ClassWithPropertiesRegisteredByNonMagicStringOverload.IntPropertyWithPropertyChangeNoticationProperty.GetDefaultValue<int>(), instance.IntPropertyWithPropertyChangeNotication);
     Assert.AreEqual(ClassWithPropertiesRegisteredByNonMagicStringOverload.IntPropertyExcludedFromSerializationAndBackupProperty.GetDefaultValue<int>(), instance.IntPropertyExcludedFromSerializationAndBackup);
 }
コード例 #2
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
        public void PropertiesAreRegisteredWithPropertyChangeNotification()
        {
            Assert.IsNotNull(ClassWithPropertiesRegisteredByNonMagicStringOverload.IntPropertyWithPropertyChangeNoticationProperty.PropertyChangedEventHandler);

            var random = new Random();
            int maxPropertyChanges = random.Next(0, 15);
            var instance = new ClassWithPropertiesRegisteredByNonMagicStringOverload();
            for (int i = 0; i < maxPropertyChanges; i++)
            {
                instance.IntPropertyWithPropertyChangeNotication = random.Next(1000);
            }

            Assert.IsTrue(0 <= instance.IntPropertyWithPropertyChangeNoticationsCount && instance.IntPropertyWithPropertyChangeNoticationsCount <= maxPropertyChanges);
        }
コード例 #3
0
ファイル: ModelBaseTest.cs プロジェクト: Catel/Catel
 public void PropertiesAreActuallyRegistered()
 {
     var instance = new ClassWithPropertiesRegisteredByNonMagicStringOverload();
     Assert.IsTrue(instance.IsPropertyRegistered("StringProperty"));
     Assert.IsTrue(instance.IsPropertyRegistered("StringPropertyWithSpecifiedDefaultValue"));
     Assert.IsTrue(instance.IsPropertyRegistered("IntPropertyWithPropertyChangeNotication"));
     Assert.IsTrue(instance.IsPropertyRegistered("IntPropertyExcludedFromSerializationAndBackup"));
 }