public void LoadResources_CheckExampleResources_DirectoryExists_False() { //------------------Arrange--------------- var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(false); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); //------------------Act------------------- var loadResources = new LoadResources("Resources - ServerTests", mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(o => o.LoadExamplesViaBuilder(It.IsAny <string>()), Times.Never); }
public void ResourceCatalog_LoadExamplesViaBuilder_ResourcesDirectoryDoesNotExist() { //------------------Arrange--------------- var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(Path.Combine(EnvironmentVariables.ApplicationPath, "Resources - Release"))).Returns(true); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.LoadExamplesViaBuilder(Path.Combine(EnvironmentVariables.ApplicationPath, "Resources - Release"))).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources("Resources - Release", new Mock <IWriter>().Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(); }
public void LoadResources_CheckExampleResources_DirectoryExists_True() { //------------------Arrange--------------- var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.LoadExamplesViaBuilder(It.IsAny <string>())) .Callback <string>((path) => Assert.IsTrue(path.EndsWith(@"\Resources - ServerTests"))) .Returns(() => null).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources("Resources - ServerTests", mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(); }