Example #1
0
        public void Test_LoadCollection_WhenHasTimedOut_ShouldReload()
        {
            //---------------Set up test pack-------------------
            var cmbox  = CreateComboBox();
            var mapper = new AutoLoadingRelationshipComboBoxMapperSpy(cmbox, "Organisation", false, GetControlFactory())
            {
                TimeOut = 5000
            };

            mapper.SetRelatedObjectClassDef(_orgClassDef);
            //---------------Assert Precondition----------------
            Assert.AreEqual(mapper.TimeOut, 5000, "Timeout setting of zero or less results in no caching");
            //---------------Execute Test ----------------------
            mapper.CallLoadCollectionForBusinessObject();
            var boColAfterCall1 = mapper.BusinessObjectCollection;

            mapper.SetLastCallTime(DateTime.Now.AddMilliseconds(-5001));
            mapper.CallLoadCollectionForBusinessObject();
            var boColAfterCall2 = mapper.BusinessObjectCollection;

            //---------------Test Result -----------------------
            Assert.IsNotNull(boColAfterCall1);
            Assert.AreNotSame(boColAfterCall1, boColAfterCall2, "Since cache has timed out should reload");
        }
 public void Test_LoadCollection_WhenHasTimedOut_ShouldReload()
 {
     //---------------Set up test pack-------------------
     var cmbox = CreateComboBox();
     var mapper =  new AutoLoadingRelationshipComboBoxMapperSpy(cmbox, "Organisation", false, GetControlFactory())
                       {TimeOut = 5000};
     mapper.SetRelatedObjectClassDef(_orgClassDef);
     //---------------Assert Precondition----------------
     Assert.AreEqual(mapper.TimeOut, 5000, "Timeout setting of zero or less results in no caching");
     //---------------Execute Test ----------------------
     mapper.CallLoadCollectionForBusinessObject();
     var boColAfterCall1 = mapper.BusinessObjectCollection;
     mapper.SetLastCallTime(DateTime.Now.AddMilliseconds(-5001));
     mapper.CallLoadCollectionForBusinessObject();
     var boColAfterCall2 = mapper.BusinessObjectCollection;
     //---------------Test Result -----------------------
     Assert.IsNotNull(boColAfterCall1);
     Assert.AreNotSame(boColAfterCall1, boColAfterCall2, "Since cache has timed out should reload");
 }