public void TestEqualsFalse() { IFilter filter1 = new TransactionTypeFilter("compra"); IFilter filter2 = new TransactionTypeFilter("alquiler"); Assert.IsFalse(filter1.Equals(filter2)); }
public void TestAskAndParseAPI() { Database database = new Database(1); Database database2 = new Database(5); APIInfoCasas apiCore = new APIInfoCasas(); ICApi api = new ICApi(); api.SetDepartment("montevideo"); api.SetPropertyTypes(new PropertyType[] { PropertyType.Apartamento }); api.SetTransactionType(TransactionType.Alquiler); api.SetCitiesAndNeighbourhoods(new string[] { "buceo" }); List <IFilter> filters = new List <IFilter>(); DepartmentFilter department = new DepartmentFilter("montevideo"); PropertyTypeFilter propertyTypeFilter = new PropertyTypeFilter("apartamento"); TransactionTypeFilter transactionTypeFilter = new TransactionTypeFilter("alquiler"); NeighbourhoodFilter neighbourhoodFilter = new NeighbourhoodFilter("buceo"); filters.Add(department); filters.Add(propertyTypeFilter); filters.Add(transactionTypeFilter); filters.Add(neighbourhoodFilter); apiCore.AskAPI(filters, 1); List <ICApiSearchResult> apiResult = api.Search(); apiCore.Parse(apiResult, 5, "buceo"); Assert.IsTrue(database.GetPropertyList().SequenceEqual(database2.GetPropertyList())); }
public void TestParseInputMultiplesFiltros() { Database database = SingleInstance <DatabaseMap> .GetInstance.GetDatabaseInstance(1); IInterpreter interpreter = new SimpleInterpreter(); // se la crea para setearla en la database debido a que eso solo se realiza de forma // automática en el programa al recibir mensajes ConsoleChannel console = new ConsoleChannel(); database.SetAdapter(console); TransactionTypeFilter transactionTypeFilter = new TransactionTypeFilter("compra"); DepartmentFilter departmentFilter = new DepartmentFilter("canelones"); PropertyTypeFilter propertyTypeFilter = new PropertyTypeFilter("casa"); List <IFilter> filters = new List <IFilter>(); filters.Add(transactionTypeFilter); filters.Add(departmentFilter); filters.Add(propertyTypeFilter); database.SetState(Status.WaitingTransactionType); interpreter.ParseInput(1, "2"); interpreter.ParseInput(1, "canelones"); interpreter.ParseInput(1, "1"); Assert.IsTrue(database.GetFilters().SequenceEqual(filters)); }
public void TestEqualsNullException() { IFilter filter1 = new TransactionTypeFilter("alquiler"); IFilter filter2 = null; // el test pasa dado que nunca se llega al Assert.Fail (el equals lanza excepción) // y se hace el catch del tipo correcto (NullReferenceException) try { filter1.Equals(filter2); Assert.Fail(); } catch (NullReferenceException) { } }
/// <summary> /// List all transactions related to the import job. The correlation is made through the tag. See summary /// </summary> /// <exception cref="FireflyIII.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key">The key of the import job</param> /// <param name="page">Page number. The default pagination is 50. (optional)</param> /// <param name="start">A date formatted YYYY-MM-DD. This is the start date of the selected range (inclusive). (optional)</param> /// <param name="end">A date formatted YYYY-MM-DD. This is the end date of the selected range (inclusive). (optional)</param> /// <param name="type">Optional filter on the transaction type(s) returned. (optional)</param> /// <returns>Task of ApiResponse (TransactionArray)</returns> public async System.Threading.Tasks.Task <FireflyIII.Client.ApiResponse <TransactionArray> > ListTransactionByImportAsyncWithHttpInfo(string key, int?page = default(int?), DateTime?start = default(DateTime?), DateTime?end = default(DateTime?), TransactionTypeFilter type = default(TransactionTypeFilter)) { // verify the required parameter 'key' is set if (key == null) { throw new FireflyIII.Client.ApiException(400, "Missing required parameter 'key' when calling ImportApi->ListTransactionByImport"); } FireflyIII.Client.RequestOptions localVarRequestOptions = new FireflyIII.Client.RequestOptions(); String[] _contentTypes = new String[] { }; // to determine the Accept header String[] _accepts = new String[] { "application/json" }; foreach (var _contentType in _contentTypes) { localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType); } foreach (var _accept in _accepts) { localVarRequestOptions.HeaderParameters.Add("Accept", _accept); } if (key != null) { localVarRequestOptions.PathParameters.Add("key", FireflyIII.Client.ClientUtils.ParameterToString(key)); // path parameter } if (page != null) { foreach (var _kvp in FireflyIII.Client.ClientUtils.ParameterToMultiMap("", "page", page)) { foreach (var _kvpValue in _kvp.Value) { localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue); } } } if (start != null) { foreach (var _kvp in FireflyIII.Client.ClientUtils.ParameterToMultiMap("", "start", start)) { foreach (var _kvpValue in _kvp.Value) { localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue); } } } if (end != null) { foreach (var _kvp in FireflyIII.Client.ClientUtils.ParameterToMultiMap("", "end", end)) { foreach (var _kvpValue in _kvp.Value) { localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue); } } } if (type != 0) { foreach (var _kvp in FireflyIII.Client.ClientUtils.ParameterToMultiMap("", "type", type)) { foreach (var _kvpValue in _kvp.Value) { localVarRequestOptions.QueryParameters.Add(_kvp.Key, _kvpValue); } } } // authentication (firefly_iii_auth) required // oauth required if (!String.IsNullOrEmpty(this.Configuration.AccessToken)) { localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken); } // make the HTTP request var localVarResponse = await this.AsynchronousClient.GetAsync <TransactionArray>("/api/v1/import/{key}/transactions", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { Exception _exception = this.ExceptionFactory("ListTransactionByImport", localVarResponse); if (_exception != null) { throw _exception; } } return(localVarResponse); }
/// <summary> /// List all transactions related to the import job. The correlation is made through the tag. See summary /// </summary> /// <exception cref="FireflyIII.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key">The key of the import job</param> /// <param name="page">Page number. The default pagination is 50. (optional)</param> /// <param name="start">A date formatted YYYY-MM-DD. This is the start date of the selected range (inclusive). (optional)</param> /// <param name="end">A date formatted YYYY-MM-DD. This is the end date of the selected range (inclusive). (optional)</param> /// <param name="type">Optional filter on the transaction type(s) returned. (optional)</param> /// <returns>Task of TransactionArray</returns> public async System.Threading.Tasks.Task <TransactionArray> ListTransactionByImportAsync(string key, int?page = default(int?), DateTime?start = default(DateTime?), DateTime?end = default(DateTime?), TransactionTypeFilter type = default(TransactionTypeFilter)) { FireflyIII.Client.ApiResponse <TransactionArray> localVarResponse = await ListTransactionByImportAsyncWithHttpInfo(key, page, start, end, type); return(localVarResponse.Data); }
/// <summary> /// List all transactions related to the import job. The correlation is made through the tag. See summary /// </summary> /// <exception cref="FireflyIII.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="key">The key of the import job</param> /// <param name="page">Page number. The default pagination is 50. (optional)</param> /// <param name="start">A date formatted YYYY-MM-DD. This is the start date of the selected range (inclusive). (optional)</param> /// <param name="end">A date formatted YYYY-MM-DD. This is the end date of the selected range (inclusive). (optional)</param> /// <param name="type">Optional filter on the transaction type(s) returned. (optional)</param> /// <returns>TransactionArray</returns> public TransactionArray ListTransactionByImport(string key, int?page = default(int?), DateTime?start = default(DateTime?), DateTime?end = default(DateTime?), TransactionTypeFilter type = default(TransactionTypeFilter)) { FireflyIII.Client.ApiResponse <TransactionArray> localVarResponse = ListTransactionByImportWithHttpInfo(key, page, start, end, type); return(localVarResponse.Data); }