public void ShouldGetAndCacheBdtLibraryByName() { // Setup var bdtLibraryMock = new Mock <IBdtLibrary>(); bdtLibraryMock.SetupGet(l => l.Name).Returns("bdtlib1"); var cctsRepositoryMock = new Mock <ICctsRepository>(); cctsRepositoryMock.Setup(r => r.GetAllLibraries()).Returns(new[] { bdtLibraryMock.Object }); // Events CcCache ccCache = CcCache.GetInstance(cctsRepositoryMock.Object); IBdtLibrary bdtLibrary = ccCache.GetBdtLibraryByName("bdtlib1"); ccCache.GetBdtLibraryByName("bdtlib1"); // Assertion and Verification Assert.That(bdtLibrary, Is.SameAs(bdtLibraryMock.Object)); cctsRepositoryMock.Verify(r => r.GetAllLibraries(), Times.Exactly(1)); }