public bool incHitFilm(int idFilm, string type)
        {
            HitDTO h = null;

            if (type.Equals("Film"))
            {
                h = svDal.getHit(idFilm, TypeEnum.Film, DateTime.Today);
            }
            else
            {
                h = svDal.getHit(idFilm, TypeEnum.Actor, DateTime.Today);
            }
            if (h == null)
            {
                if (type.Equals("Film"))
                {
                    //hit non existant faut ajouter
                    h = new HitDTO(idFilm, TypeEnum.Film, DateTime.Today, 1);
                    return(svDal.addHit(h));
                }
                else
                {
                    h = new HitDTO(idFilm, TypeEnum.Actor, DateTime.Today, 1);
                    return(svDal.addHit(h));
                }
            }
            h.Hit++;
            return(svDal.updateHit(h));;
        }
Esempio n. 2
0
        public void GetHashOfSearchResults_Returns_Same_Hash_WhenCallingForSameSearchResult()
        {
            var SearchHitList = new List <SearchHit>();
            var SearchHit     = new SearchHit();
            var SearchHit2    = new SearchHit();

            SearchHit.Source.Add("http://pid.bayer.com/kos/19014/hasPID", JObject.Parse("{ \"outbound\": [ { \"value\": \"https://dev-pid.bayer.com/kos/test1\", \"uri\": \"https://dev-pid.bayer.com/kos/test1\", \"edge\": \"http://pid.bayer.com/kos/19014/hasPID\" } ], \"inbound\": [] }"));
            SearchHit.Source.Add("https://pid.bayer.com/kos/19050/lastChangeDateTime", JObject.Parse("{ \"outbound\": [ { \"value\": \"2021-02-01T09:07:25.327Z\", \"uri\": null, \"edge\": null } ], \"inbound\": [] }"));
            SearchHit.Source.Add("https://pid.bayer.com/kos/19050/dateCreated", JObject.Parse("{ \"outbound\": [ { \"value\": \"2021-02-01T09:06:30.452Z\", \"uri\": null, \"edge\": null } ], \"inbound\": [] }"));

            SearchHit2.Source.Add("http://pid.bayer.com/kos/19014/hasPID", JObject.Parse("{ \"outbound\": [ { \"value\": \"https://dev-pid.bayer.com/kos/test2\", \"uri\": \"https://dev-pid.bayer.com/kos/test2\", \"edge\": \"http://pid.bayer.com/kos/19014/hasPID\" } ], \"inbound\": [] }"));
            SearchHit2.Source.Add("https://pid.bayer.com/kos/19050/lastChangeDateTime", JObject.Parse("{ \"outbound\": [ { \"value\": \"2021-02-08T09:07:25.327Z\", \"uri\": null, \"edge\": null } ], \"inbound\": [] }"));
            SearchHit2.Source.Add("https://pid.bayer.com/kos/19050/dateCreated", JObject.Parse("{ \"outbound\": [ { \"value\": \"2021-02-08T09:06:30.452Z\", \"uri\": null, \"edge\": null } ], \"inbound\": [] }"));
            SearchHitList.Add(SearchHit);
            SearchHitList.Add(SearchHit2);
            var Hits = new HitDTO()
            {
                Total = SearchHitList.Count,
                Hits  = SearchHitList
            };
            var searchResult = new SearchResultDTO("testForProcessingStoredQueries", null, Hits);

            string computedHash  = _service.GetHashOfSearchResults(searchResult);
            string computedHash2 = _service.GetHashOfSearchResults(searchResult);

            Assert.NotEmpty(computedHash);
            Assert.NotEmpty(computedHash2);
            Assert.Equal(computedHash, computedHash2);
        }
        public bool updateHit(HitDTO h)
        {
            Hit newh = new Hit {
                id = h.Id, type = (int)h.Type, date = h.Date, hit = h.Hit
            };

            return(Update <Hit>(newh, xg => xg.id == newh.id && xg.type == newh.type && xg.date == newh.date));
        }
Esempio n. 4
0
        private void SetupSearchService(List <SearchHit> SearchHitList)
        {
            var Hits = new HitDTO()
            {
                Total = SearchHitList.Count,
                Hits  = SearchHitList
            };
            var searchResult = new SearchResultDTO("testForProcessingStoredQueries", null, Hits);

            _mockRemoteSearchService.Setup(mock => mock.Search(It.IsAny <SearchRequestDto>())).Returns(Task.FromResult(searchResult));
        }
Esempio n. 5
0
        public void GetHashOfSearchResults_Returns_hash_WhenSearchResultIsEmpty()
        {
            var SearchHitList = new List <SearchHit>();

            var Hits = new HitDTO()
            {
                Total = SearchHitList.Count,
                Hits  = SearchHitList
            };
            var searchResult = new SearchResultDTO("testForProcessingStoredQueries", null, Hits);

            string computedHash = _service.GetHashOfSearchResults(searchResult);

            Assert.NotEmpty(computedHash);
        }