示例#1
0
        public void Int参照コレクションをモデルに書きこむことができる()
        {
            var collection = new ComplicateCollectionProperty(typeof(Hoge[]), new PropertyFactory());
            ReferencableMasterInfo source = new ReferencableMasterInfo()
            {
                Collection = collection.Collection.ToReadOnlyReactiveCollection(x => x.Value.Value),
                Type       = typeof(Hoge),
            };
            var model      = new ReferenceByIntCollectionProperty(source, "Id", new PropertyFactory());
            var value      = new int[] { 12, 13, 14 };
            var references = new References();

            Load(model, value, references);

            var ref0 = model.Collection[0].IsInstanceOf <ReferenceByIntProperty>();
            var ref1 = model.Collection[1].IsInstanceOf <ReferenceByIntProperty>();
            var ref2 = model.Collection[2].IsInstanceOf <ReferenceByIntProperty>();

            references[0].id.Is(12);
            references[0].reference.Is(ref0);
            references[1].id.Is(13);
            references[1].reference.Is(ref1);
            references[2].id.Is(14);
            references[2].reference.Is(ref2);
        }
示例#2
0
        public void ComplicateCollectionをモデルに書きこむことができる()
        {
            var model = new ComplicateCollectionProperty(typeof(Hoge[]), new PropertyFactory());
            var value = new Hoge[]
            {
                new Hoge {
                    X = 91
                },
                new Hoge {
                    X = 82
                },
                new Hoge {
                    X = 73
                },
            };

            Load(model, value);

            var hoge0 = model.Collection[0].Value.Value.IsInstanceOf <Hoge>();

            hoge0.X.Is(91);
            var hoge1 = model.Collection[1].Value.Value.IsInstanceOf <Hoge>();

            hoge1.X.Is(82);
            var hoge2 = model.Collection[2].Value.Value.IsInstanceOf <Hoge>();

            hoge2.X.Is(73);
        }
示例#3
0
        public void ComplicateCollectionOnAddingTest()
        {
            bool isCalled = false;
            var  factory  = new PropertyFactory();
            var  prop     = new ComplicateCollectionProperty(typeof(MyClass[]), factory);
            var  vm       = new ComplicateCollectionViewModel(prop, new ViewModelFactory(factory, false));

            vm.OnChanged.Subscribe(x => isCalled = true);

            vm.AddCommand.Execute();
            isCalled.IsTrue();
        }
示例#4
0
        public void AddNewElementTest()
        {
            var property = new ComplicateCollectionProperty(typeof(TestClass[]), new PropertyFactory());

            property.AddNewElement();

            property.Collection.ToArray().Length.Is(1);
            property.Collection[0].Title.Value.Is(CollectionHolder.ElementTitle);
            property.Collection[0].IsInstanceOf <ClassProperty>();

            var e1 = property.Collection[0] as ClassProperty;

            e1.Members.Length.Is(2);
            e1.Members[0].IsInstanceOf <IntProperty>();
            e1.Members[1].IsInstanceOf <StringProperty>();
        }
示例#5
0
        public void  換中にReferenceByIntが来たら参照情報に書き込む()
        {
            var collection = new ComplicateCollectionProperty(typeof(Hoge[]), new PropertyFactory());
            ReferencableMasterInfo source = new ReferencableMasterInfo()
            {
                Collection = collection.Collection.ToReadOnlyReactiveCollection(x => x.Value.Value),
                Type       = typeof(Hoge),
            };
            var refModel   = new ReferenceByIntProperty(source, "Id");
            var references = new References();

            Load(refModel, 12, references);

            references[0].id.Is(12);
            references[0].reference.Is(refModel);
        }
示例#6
0
        public void RemoveElementAtTest()
        {
            var property = new ComplicateCollectionProperty(typeof(TestClass[]), new PropertyFactory());
            var ee1      = property.AddNewElement() as ClassProperty;
            var ee2      = property.AddNewElement() as ClassProperty;

            (ee1.Members[0] as IntProperty).IntValue.Value = 1;
            (ee2.Members[0] as IntProperty).IntValue.Value = 2;

            property.RemoveElementAt(0);
            property.Collection.Count.Is(1);

            var e1   = property.Collection[0] as ClassProperty;
            var e1m1 = e1.Members[0] as IntProperty;

            e1m1.IntValue.Value.Is(2);
        }
 public SubtypingClassCollectionViewModel(ComplicateCollectionProperty property, ViewModelFactory factory)
     : base(property, factory)
 {
 }
示例#8
0
        public void RemoveFromEmptyTest()
        {
            var prop = new ComplicateCollectionProperty(typeof(TestClass[]), new PropertyFactory());

            prop.RemoveElementAt(-1);
        }