public void FileExistsTest_VPPRegistrationChanging() { // Arrange string path = "~/Index.cshtml"; Mock <VirtualPathProvider> mockProvider = new Mock <VirtualPathProvider>( MockBehavior.Strict ); mockProvider .Setup(c => c.FileExists(It.IsAny <string>())) .Returns <string>(p => p.Equals(path)) .Verifiable(); VirtualPathProvider provider = null; // Act FileExistenceCache cache = new FileExistenceCache(() => provider); // The moral equivalent of HostingEnvironment.RegisterVirtualPathProvider(mockProvider.Object) provider = mockProvider.Object; bool createExists = cache.FileExists("~/Create.cshtml"); bool indexExists = cache.FileExists(path); // Assert Assert.False(createExists); Assert.True(indexExists); mockProvider.Verify(); mockProvider.Verify(vpp => vpp.FileExists(It.IsAny <string>()), Times.Exactly(2)); }
public void FileExistsVppLaterTest() { var path = "~/index.cshtml"; var cache = new FileExistenceCache(GetVpp(path)); Assert.True(cache.FileExists(path)); Assert.False(cache.FileExists("~/test.cshtml")); }
public void FileExistsVppLaterTest() { var path = "~/index.cshtml"; var cache = new FileExistenceCache(GetVpp(path)); Assert.True(cache.FileExists(path)); Assert.False(cache.FileExists("~/test.cshtml")); }
public void FileExistsTimeExceededTest() { var path = "~/index.cshtml"; Utils.SetupVirtualPathInAppDomain(path, ""); var cache = new FileExistenceCache(GetVpp(path)); var cacheInternal = cache.CacheInternal; cache.MilliSecondsBeforeReset = 5; Thread.Sleep(300); Assert.True(cache.FileExists(path)); Assert.False(cache.FileExists("~/test.cshtml")); Assert.NotEqual(cacheInternal, cache.CacheInternal); }
public void FileExistsTimeExceededTest() { var path = "~/index.cshtml"; Utils.SetupVirtualPathInAppDomain(path, ""); var cache = new FileExistenceCache(GetVpp(path)); var cacheInternal = cache.CacheInternal; cache.MilliSecondsBeforeReset = 5; Thread.Sleep(300); Assert.True(cache.FileExists(path)); Assert.False(cache.FileExists("~/test.cshtml")); Assert.NotEqual(cacheInternal, cache.CacheInternal); }
public void FileExistsTest_VPPRegistrationChanging() { // Arrange string path = "~/Index.cshtml"; Mock<VirtualPathProvider> mockProvider = new Mock<VirtualPathProvider>(MockBehavior.Strict); mockProvider.Setup(c => c.FileExists(It.IsAny<string>())).Returns<string>(p => p.Equals(path)).Verifiable(); VirtualPathProvider provider = null; // Act FileExistenceCache cache = new FileExistenceCache(() => provider); // The moral equivalent of HostingEnvironment.RegisterVirtualPathProvider(mockProvider.Object) provider = mockProvider.Object; bool createExists = cache.FileExists("~/Create.cshtml"); bool indexExists = cache.FileExists(path); // Assert Assert.False(createExists); Assert.True(indexExists); mockProvider.Verify(); mockProvider.Verify(vpp => vpp.FileExists(It.IsAny<string>()), Times.Exactly(2)); }