コード例 #1
0
        public void Test_GetPostedEntities_AutoLoadPostEntitiesTrue()
        {
            TestRecord record = new TestRecord();
            record.ID = Guid.NewGuid();

            EntitySelect<TestRecord> ctrl = new EntitySelect<TestRecord>();
            ctrl.AutoLoadPostEntities = true;
            ctrl.EntityType = record.GetType().FullName + ", " + typeof(TestRecord).Assembly.GetName().Name;
            ctrl.RequireAuthorisation = false; // Only false during testing

            Guid[] ids = new Guid[] { record.ID };

            SaveStrategy.New(record, false).Save(record);

            IEntity[] entities = ctrl.GetPostedEntities(ids);

            Assert.IsNotNull(entities, "Returned null");

            // The entity should have been loaded automatically
            Assert.AreEqual(1, entities.Length, "Invalid number of entities returned.");
        }
コード例 #2
0
        public void Test_GetPostedEntities_AutoLoadPostEntitiesFalse()
        {
            TestRecord record = new TestRecord();
            record.ID = Guid.NewGuid();

            EntitySelect<TestRecord> ctrl = new EntitySelect<TestRecord>();
            ctrl.AutoLoadPostEntities = false;
            ctrl.EntityType = record.GetType().FullName + ", " + typeof(TestRecord).Assembly.GetName().Name;
            ctrl.RequireAuthorisation = false; // Only false during testing

            Guid[] ids = new Guid[] { record.ID };

            SaveStrategy.New(record, false).Save(record);

            IEntity[] entities = ctrl.GetPostedEntities(ids);

            Assert.IsNotNull(entities, "Returned null");

            // No entities should be returned because they weren't found on DataSource
            Assert.AreEqual(0, entities.Length, "Invalid number of entities returned.");
        }