Ejemplo n.º 1
0
        public void ShouldGetAndCacheAllCdtsFromCdtLibrary()
        {
            // Setup
            var cdtMock        = new Mock <ICdt>();
            var cdtLibraryMock = new Mock <ICdtLibrary>();

            ICdt[] expectedCdts = new[] { cdtMock.Object, cdtMock.Object, cdtMock.Object };
            cdtLibraryMock.SetupGet(l => l.Name).Returns("cdtlib1");
            cdtLibraryMock.SetupGet(l => l.Cdts).Returns(expectedCdts);

            var cctsRepositoryMock = new Mock <ICctsRepository>();

            cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(new[] { cdtLibraryMock.Object });

            // Events
            CcCache     ccCache = CcCache.GetInstance(cctsRepositoryMock.Object);
            List <ICdt> cdts    = ccCache.GetCdtsFromCdtLibrary("cdtlib1");

            ccCache.GetCdtsFromCdtLibrary("cdtlib1");

            // Assertion and Verification
            Assert.That(cdts, Is.EquivalentTo(expectedCdts));
            cdtLibraryMock.VerifyGet(l => l.Cdts, Times.Exactly(1));
        }