Пример #1
0
        public void ShouldGetAndCacheAllBdtsFromBdtLibrary()
        {
            // Setup
            var bdtMock        = new Mock <IBdt>();
            var bdtLibraryMock = new Mock <IBdtLibrary>();

            IBdt[] expectedBdts = new[] { bdtMock.Object, bdtMock.Object, bdtMock.Object };
            bdtLibraryMock.SetupGet(l => l.Name).Returns("bdtlib1");
            bdtLibraryMock.SetupGet(l => l.Bdts).Returns(expectedBdts);

            var cctsRepositoryMock = new Mock <ICctsRepository>();

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

            // Events
            CcCache     ccCache = CcCache.GetInstance(cctsRepositoryMock.Object);
            List <IBdt> bdts    = ccCache.GetBdtsFromBdtLibrary("bdtlib1");

            ccCache.GetBdtsFromBdtLibrary("bdtlib1");

            // Assertion and Verification
            Assert.That(bdts, Is.EquivalentTo(expectedBdts));
            bdtLibraryMock.VerifyGet(l => l.Bdts, Times.Exactly(1));
        }