Пример #1
0
        public void ShouldRefreshCacheToForceReloadOfBdtAndBieLibrary()
        {
            // Setup
            var bdtLibraryMock       = new Mock <IBdtLibrary>();
            var bieLibraryMock       = new Mock <IBieLibrary>();
            var expectedBieLibraries = new[] { bieLibraryMock.Object };
            var expectedBdtLibraries = new[] { bdtLibraryMock.Object };
            var allLibraries         = new List <object>();

            allLibraries.AddRange(expectedBieLibraries);
            allLibraries.AddRange(expectedBdtLibraries);
            var cctsRepositoryMock = new Mock <ICctsRepository>();

            cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(allLibraries);

            // Events
            CcCache            ccCache      = CcCache.GetInstance(cctsRepositoryMock.Object);
            List <IBieLibrary> bieLibraries = ccCache.GetBieLibraries();
            List <IBdtLibrary> bdtLibraries = ccCache.GetBdtLibraries();

            ccCache.GetBieLibraries();
            ccCache.GetBdtLibraries();

            ccCache.Refresh();

            ccCache.GetBieLibraries();
            ccCache.GetBdtLibraries();
            ccCache.GetBieLibraries();
            ccCache.GetBdtLibraries();

            // Assertion and Verification
            Assert.That(bdtLibraries, Is.EquivalentTo(expectedBdtLibraries));
            Assert.That(bieLibraries, Is.EquivalentTo(expectedBieLibraries));
            cctsRepositoryMock.Verify(r => r.GetAllLibraries(), Times.Exactly(2));
        }
 public void Reset()
 {
     ccCache.Refresh();
     //this has to be used to reset current UI state:
     //mCandidateBdtLibraries = new List<CandidateBdtLibrary>(ccCache.GetBdtLibraries().ConvertAll(bdtl => new CandidateBdtLibrary(bdtl)));
     //CandidateBdtLibraryNames = new List<string>(mCandidateBdtLibraries.ConvertAll(bdtlname => bdtlname.OriginalBdtLibrary.Name));
     //mCandidateCdtLibraries = new List<CandidateCdtLibrary>(ccCache.GetCdtLibraries().ConvertAll(cdtl => new CandidateCdtLibrary(cdtl)));
     //CandidateCdtLibraryNames = new List<string>(mCandidateCdtLibraries.ConvertAll(cdtlname => cdtlname.OriginalCdtLibrary.Name));
     //CandidateCdtNames = new List<string>();
     //CandidateSupItems = new List<CheckableItem>();
     //CandidateConItems = new List<CheckableItem>();
 }