private static HttpState SetupHttpState(string preferencesFileContent = null) { UserProfileDirectoryProvider userProfileDirectoryProvider = new UserProfileDirectoryProvider(); IFileSystem fileSystem; if (preferencesFileContent != null) { fileSystem = new MockedFileSystem(); } else { fileSystem = new FileSystemStub(); } UserFolderPreferences preferences = new UserFolderPreferences(fileSystem, userProfileDirectoryProvider, null); if (preferencesFileContent != null) { ((MockedFileSystem)fileSystem).AddFile(preferences.PreferencesFilePath, preferencesFileContent); } HttpClient client = new HttpClient(); HttpState state = new HttpState(fileSystem, preferences, client); return(state); }
private static HttpState SetupHttpState() { IFileSystem fileSystem = new FileSystemStub(); IUserProfileDirectoryProvider userProfileDirectoryProvider = new UserProfileDirectoryProvider(); IPreferences preferences = new UserFolderPreferences(fileSystem, userProfileDirectoryProvider, null); HttpClient httpClient = new HttpClient(); return(new HttpState(fileSystem, preferences, httpClient)); }
private static HttpState SetupHttpState() { IFileSystem fileSystem = new FileSystemStub(); IUserProfileDirectoryProvider userProfileDirectoryProvider = new UserProfileDirectoryProvider(); IPreferences preferences = new UserFolderPreferences(fileSystem, userProfileDirectoryProvider, null); HttpClient httpClient = new HttpClient(); HttpState httpState = new HttpState(fileSystem, preferences, httpClient); DirectoryStructure structure = new DirectoryStructure(null); DirectoryStructure child1 = structure.DeclareDirectory("child1"); structure.DeclareDirectory("child2"); child1.DeclareDirectory("grandchild1"); child1.DeclareDirectory("grandchild2"); httpState.Structure = structure; return(httpState); }
public void ContextSetup() { var filePath = @"C:\some\dir\myfile.json"; _stubbedJson = "I am some json, I promise (just kidding)"; var model = new MasterModel(); _fileSystem = new FileSystemStub(); var jsonSerializer = S <IJsonSerializerService>(); jsonSerializer.Stub(x => x.SerializeMasterModel(model)).Return(_stubbedJson); var configuration = new StubApplicationConfiguration { StorageFilePath = filePath }; var storage = new FileSystemStorage(_fileSystem, jsonSerializer, configuration); storage.Save(model); _result = _fileSystem.GetLastWriteTo(filePath); }
public void ContextSetup() { const string filePath = @"C:\some\dir"; const string stubbedJson = "I am some json, I promise (just kidding)"; _stubbedModel = new MasterModel(); var fileSystem = new FileSystemStub(); fileSystem.StubContentForPath(filePath, stubbedJson); var jsonSerializer = S <IJsonSerializerService>(); jsonSerializer.Stub(x => x.DeserializeMasterModel(stubbedJson)).Return(_stubbedModel); var configuration = new StubApplicationConfiguration { StorageFilePath = filePath }; var storage = new FileSystemStorage(fileSystem, jsonSerializer, configuration); _result = storage.ReadMasterModel(); }