Beispiel #1
0
        public void A()
        {
            var enumBM = new EnumBM <TestEnum>();

            Assert.IsTrue(enumBM.HasValue);
            Assert.AreEqual(default(TestEnum), enumBM.Value);
        }
Beispiel #2
0
        public void B()
        {
            var enumBM = new EnumBM <TestEnum>();

            enumBM.Metadata.DataProvider.Data = TestEnum.A;
            Assert.IsNotNull(enumBM.Settings);
            Assert.IsTrue(enumBM.Settings.IncludeValuesSpecified);
            Assert.IsNotNull(enumBM.Settings.IncludeValues);

            var enumVM = new EnumVM <TestEnum> {
                Metadata = new BusinessValueMetadata <TestEnum>()
            };

            ((BusinessValueDataProvider <TestEnum>)enumVM.Metadata.DataProvider).BusinessValue = enumBM;

            Assert.That(enumVM.DisplayValueProvider, Is.TypeOf <EnumDisplayValueProvider>());

            Assert.AreEqual(TestEnum.A, enumVM.Value);
            Assert.AreEqual("A", enumVM.DisplayValueProvider.String);
            Assert.AreEqual("A", enumVM.EditValueProvider.String);

            Assert.IsNotNull(enumVM.ValueSourceProvider);
            Assert.IsNotNull(enumVM.ValueSourceProvider.SourceList);

            var validValues = enumVM.ValueSourceProvider.SourceList.Cast <EnumMemberVM <TestEnum> >().ToList();

            Assert.AreEqual(3, validValues.Count);

            enumVM.Value = TestEnum.B;
            Assert.AreEqual(TestEnum.B, enumBM.Value);

            enumVM.EditValueProvider.String = "C";
            Assert.IsFalse(enumVM.ErrorProvider.HasError);
            Assert.AreEqual(TestEnum.C, enumBM.Value);
        }
Beispiel #3
0
        public void BusinessValueDataProvider_BusinessValue_Settings_IncludeValues_changed_while_value_is_selected()
        {
            var enumBM = new EnumBM <TestEnum>();
            var enumVM = new EnumVM <TestEnum> {
                Metadata = new BusinessValueMetadata <TestEnum>()
            };

            ((BusinessValueDataProvider <TestEnum>)enumVM.Metadata.DataProvider).BusinessValue = enumBM;

            //A selected and A removed from IncludeValues should result in ErrorProvider.HasError=true
            ((ObservableCollection <TestEnum>)enumBM.Metadata.Settings.IncludeValues).RemoveAt(0);             // C removed
            Assert.AreEqual(2, enumVM.ValueSourceProvider.SourceList.Count());
            Assert.IsTrue(enumVM.ErrorProvider.HasError);
        }
Beispiel #4
0
        public void BusinessValueDataProvider_BusinessValue_Settings_IncludeValues_changed()
        {
            var enumBM = new EnumBM <TestEnum>();
            var enumVM = new EnumVM <TestEnum> {
                Metadata = new BusinessValueMetadata <TestEnum>()
            };

            ((BusinessValueDataProvider <TestEnum>)enumVM.Metadata.DataProvider).BusinessValue = enumBM;
            ((ObservableCollection <TestEnum>)enumBM.Metadata.Settings.IncludeValues).RemoveAt(1);            // B removed
            Assert.AreEqual(2, enumVM.ValueSourceProvider.SourceList.Count());

            enumVM.EditValueProvider.String = "B";
            Assert.IsTrue(enumVM.ErrorProvider.HasError);
            Assert.IsNotNull(enumVM.ErrorProvider.ErrorMessage);
            Assert.AreNotEqual("", enumVM.ErrorProvider.ErrorMessage);
            Assert.AreEqual(TestEnum.A, enumVM.Value);

            enumVM.EditValueProvider.String = "C";
            Assert.IsFalse(enumVM.ErrorProvider.HasError);
            Assert.IsNull(enumVM.ErrorProvider.ErrorMessage);
            Assert.AreEqual(TestEnum.C, enumVM.Value);
        }