public void GetCredentialById_HasPersistedCredential_Success() { var filePath = Path.Combine(Path.GetTempPath(), "credentials.json"); var storedCredential = new Credential { Id = 1, Password = "******", Login = "******" }; try { var storage = CredentialsStorage.Open(filePath); storage.SetCredential(storedCredential); storage.Save(); //act var credentialsStorage = CredentialsStorage.Open(filePath); var credential = credentialsStorage.GetCredentialById(1); Assert.IsNotNull(credential); Assert.AreEqual(storedCredential.Password, credential.Password); Assert.AreEqual(storedCredential.Id, credential.Id); Assert.AreEqual(storedCredential.Login, credential.Login); } finally { File.Delete(filePath); } }
public void Save_NoFileExists_FileCreated() { var filePath = Path.Combine(Path.GetTempPath(), "credentials.json"); Assert.IsFalse(File.Exists(filePath)); var storedCredential = new Credential { Id = 1, Password = "******", Login = "******" }; try { var storage = CredentialsStorage.Open(filePath); storage.SetCredential(storedCredential); storage.Save(); Assert.IsTrue(File.Exists(filePath)); } finally { File.Delete(filePath); } }
public void GetCredentialById_NotContainsCredentialWithSuchId_NoResult() { var filePath = Path.Combine(Path.GetTempPath(), "credentials.json"); try { var storage = CredentialsStorage.Open(filePath); storage.SetCredential(new Credential { Id = 1, Password = "******", Login = "******" }); storage.Save(); var credentialsStorage = CredentialsStorage.Open(filePath); var credential = credentialsStorage.GetCredentialById(100500); Assert.IsNull(credential); } finally { File.Delete(filePath); } }
private void Awake() { var storagePath = #if UNITY_STANDALONE_WIN ProfilesManagement.WINDOWS_PROFILES_PATH; #elif UNITY_STANDALONE_LINUX ProfilesManagement.LINUX_PROFILES_PATH; #else Path.Combine(Application.persistentDataPath, "Hoard", "Profiles"); #endif // Singletons initialization new HoardSettings(new UnitySettingsPersistency()); ProfilesManagement.CreateSingleton(storagePath); CredentialsStorage.InitializeStorage(storagePath); }
public void GetCredentialById_EmptyStorage_NoResult() { var filePath = Path.Combine(Path.GetTempPath(), "credentials.json"); try { var storage = CredentialsStorage.Open(filePath); storage.Save(); var credentialsStorage = CredentialsStorage.Open(filePath); var credential = credentialsStorage.GetCredentialById(100500); Assert.IsNull(credential); } finally { File.Delete(filePath); } }
private static void Main(string[] args) { var el1 = new Credential { Login = "******", Password = "******", Id = 1 }; var el2 = new Credential { Login = "******", Password = "******", Id = 2 }; var el3 = new Credential { Login = "******", Password = "******", Id = 3 }; var credentialsStorage = CredentialsStorage.Open("C:\\credentials.json"); credentialsStorage.SetCredential(el1); credentialsStorage.SetCredential(el2); credentialsStorage.SetCredential(el3); credentialsStorage.Save(); var first = credentialsStorage.GetCredentialById(1); }
public void GetCredentialById_NoFileStorageExists_NoResult() { CredentialsStorage credentialsStorage = CredentialsStorage.Open("C:\\no-file-exists.json"); Assert.IsNull(credentialsStorage.GetCredentialById(100500)); }