Esempio n. 1
0
        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 TestEqualsFalse()
        {
            IFilter filter1 = new NeighbourhoodFilter("parque batlle");
            IFilter filter2 = new NeighbourhoodFilter("buceo");

            Assert.IsFalse(filter1.Equals(filter2));
        }
        public void TestEqualsTrue()
        {
            IFilter filter1 = new NeighbourhoodFilter("buceo");
            IFilter filter2 = new NeighbourhoodFilter("buceo");

            Assert.IsTrue(filter1.Equals(filter2));
        }
        public void TestEqualsNullException()
        {
            IFilter filter1 = new NeighbourhoodFilter("carrasco norte");
            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)
            {
            }
        }
Esempio n. 5
0
        public void TestGetFilters()
        {
            Database database = new Database(1);

            List <IFilter> filters = new List <IFilter>();

            database.AddFilter(new PropertyTypeFilter("casa"));
            database.AddFilter(new NeighbourhoodFilter("axh"));
            database.AddFilter(new DepartmentFilter("fsgf"));

            IFilter filter1 = new PropertyTypeFilter("casa");
            IFilter filter2 = new NeighbourhoodFilter("axh");
            IFilter filter3 = new DepartmentFilter("fsgf");

            filters.Add(filter1);
            filters.Add(filter2);
            filters.Add(filter3);

            Assert.IsTrue(database.GetFilters().SequenceEqual(filters));
        }