예제 #1
0
        public void T003_TargetChangedEvent_MustRaised()
        {
            var refVM = new RefVM <StringVM>();
            int targetChangedCounter = 0;

            refVM.TargetChangedEvent.Register(this, "TargetChanged", (s, e) => targetChangedCounter++);
            refVM.Target = new StringVM();
            Assert.AreEqual(1, targetChangedCounter);
        }
예제 #2
0
        public void T002_TargetChanged_MustRaised()
        {
            var refVM = new RefVM <StringVM>();
            int targetChangedCounter = 0;

#pragma warning disable 618
            refVM.TargetChanged += (s, e) => targetChangedCounter++;
#pragma warning restore 618
            refVM.Target = new StringVM();
            Assert.AreEqual(1, targetChangedCounter);
        }
        public void Test_ObjectVM()
        {
            TestDM dm = null;
            var    bm = new RefBM <TestBM> {
                Metadata = new BusinessObjectMetadata {
                    DataProvider = new CustomDataProvider <TestDM>(() => dm, value => dm = value)
                }
            };
            var vm = new RefVM <TestVM>();

            vm.Metadata.DataProvider.Data = bm;

            Assert.That(vm.Target, Is.Null, "vm.Target");

            #region change ref in business layer
            //var bmRef1=new TestBM{Metadata = {DataProvider = {Data = new TestDM{Test="1"}}}};
            var bmRef1 = new TestBM();
            var p      = bmRef1.Metadata.DataProvider;
            var dm1    = new TestDM {
                Test = "1"
            };
            p.Data    = dm1;
            bm.Target = bmRef1;

            Assert.That(dm, Is.Not.Null, "dm");
            Assert.That(dm.Test, Is.EqualTo("1"), "m.Test");
            Assert.That(vm.Target.Test, Is.EqualTo("1"), "vm.Target.Test");
            #endregion

            #region change ref in viewmodel layer
            var bmRef2 = new TestBM {
                Metadata = { DataProvider              = { Data = new TestDM {
                                                               Test          = "2"
                                                           } } }
            };
            var vmRef2 = new TestVM {
                Metadata = { DataProvider = { Data = bmRef2 } }
            };
            vm.Target = vmRef2;

            Assert.AreEqual("2", dm.Test);
            Assert.AreEqual("2", bm.Target.Test);
            #endregion

//			#region change ref in viewmodel layer
//			var bmRef2=new TestBM{Test = "2"};
//			var vmRef2 = new TestVM {Metadata = {DataProvider = {Data = bmRef2}}};
//			vm.Ref = vmRef2;
//
//			Assert.AreEqual("2",bm.Ref.Test);
//			#endregion
        }
        [Test, Ignore("TODO")]       //TODO Test RefVM with StringVM->StringBM
        public void Test_StringVM()
        {
            var bm = new RefBM <StringBM>();
            var vm = new RefVM <StringVM> {
                Metadata = new BusinessReferenceViewModelMetadata <StringVM, StringBM>()
            };

            vm.Metadata.DataProvider.Data = bm;

            Assert.AreEqual(null, vm.Target);

            #region change ref in business layer
            var newBM = new StringBM {
                Metadata = { DataProvider = { Data = "2" } }
            };
            bm.Target = newBM;

            Assert.AreEqual("2", vm.Target.Value);
            #endregion
        }
        public ActionResult Reference()
        {
            //this will return 1 row from db with id 0f 2
            var context   = new ConstructionEntities();
            var container = new Reference();

            container = context.Reference.Where(m => m.Id == 1).FirstOrDefault();

            //this will return multiple rows eg dispaly all users in the company
            var listOfRefs = new List <Reference>();

            listOfRefs = context.Reference.ToList();



            var vm = new RefVM();

            vm.list = listOfRefs;



            return(View(vm));
        }
예제 #6
0
        public void T001_Target_Set()
        {
            var refVM = new RefVM <StringVM>();

            refVM.Target = new StringVM();
        }