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

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

            mapper.CallLoadCollectionForBusinessObject();
            var boColAfterCall2 = mapper.BusinessObjectCollection;

            //---------------Test Result -----------------------
            Assert.IsNotNull(boColAfterCall1);
            Assert.AreNotSame(boColAfterCall1, boColAfterCall2, "Since there is no timeout 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");
 }
        public void Test_LoadCollection_WithingTimeOut_ShouldNotReload()
        {
            //---------------Set up test pack-------------------
            var cmbox = CreateComboBox();
            var mapper =  new AutoLoadingRelationshipComboBoxMapperSpy(cmbox, "Organisation", false, GetControlFactory())
                              {TimeOut = 5000};
            mapper.SetRelatedObjectClassDef(_orgClassDef);
            //---------------Assert Precondition----------------
            Assert.Greater(mapper.TimeOut, 0, "Timeout setting of zero or less results in no caching");
            //---------------Execute Test ----------------------
            mapper.CallLoadCollectionForBusinessObject();
            var boColAfterCall1 = mapper.BusinessObjectCollection;

            mapper.CallLoadCollectionForBusinessObject();
            var boColAfterCall2 = mapper.BusinessObjectCollection;
            //---------------Test Result -----------------------
            Assert.IsNotNull(boColAfterCall1);
            Assert.AreSame(boColAfterCall1, boColAfterCall2, "Since both calls are withing timeout should not reload");
        }