public async Task CheckDatePublishedOnAlgoVisibilityChange()
        {
            // Create an algo
            AlgoDataDTO algoData = await CreateAlgo();

            // Get the test algo
            AlgoEntity algo = await AlgoRepository.TryGetAsync(algoData.ClientId, algoData.Id) as AlgoEntity;

            Assert.That(algoData.AlgoVisibility, Is.EqualTo(AlgoVisibility.Private));
            Assert.That(algoData.DatePublished, Is.Null);

            // Build the body for the request
            var model = new AddToPublicDTO
            {
                ClientId = algo.ClientId,
                AlgoId   = algo.AlgoId
            };

            // Change algo's visibility to 'public'
            var changeAlgoVisibility = await Consumer.ExecuteRequest(ApiPaths.ALGO_STORE_ADD_TO_PUBLIC, Helpers.EmptyDictionary, JsonUtils.SerializeObject(model), Method.POST);

            Assert.That(changeAlgoVisibility.Status, Is.EqualTo(HttpStatusCode.OK));

            // Get the test algo
            algo = await AlgoRepository.TryGetAsync(algoData.ClientId, algoData.Id) as AlgoEntity;

            // Check if the algo's visibility is successfully changed and DataPublished is available
            Assert.That(algo.AlgoVisibility, Is.EqualTo(AlgoVisibility.Public));
            Assert.That(algo.DatePublished.Value, Is.EqualTo(DateTime.UtcNow).Within(3).Minutes);

            // Change the current algo's visibility to be 'private'
            changeAlgoVisibility = await Consumer.ExecuteRequest(ApiPaths.ALGO_STORE_REMOVE_FROM_PUBLIC, Helpers.EmptyDictionary, JsonUtils.SerializeObject(model), Method.POST);

            Assert.That(changeAlgoVisibility.Status, Is.EqualTo(HttpStatusCode.OK));

            // Get the test algo with the changes
            algo = await AlgoRepository.TryGetAsync(algoData.ClientId, algoData.Id) as AlgoEntity;

            //Check if the algo's visibility is 'private' and DatePublished is NULL
            Assert.That(algo.AlgoVisibility, Is.EqualTo(AlgoVisibility.Private));
            Assert.That(algo.DatePublished, Is.Null);
        }
コード例 #2
0
        public async Task <bool> AlgoExists(AlgoDataDTO algoDataDTO)
        {
            List <AlgoEntity> allUserAlgos = await AlgoRepository.GetAllAsync(t => t.ClientId == algoDataDTO.ClientId) as List <AlgoEntity>;

            return(allUserAlgos.Exists(x => x.AlgoId == algoDataDTO.Id));
        }