Beispiel #1
0
        public async Task <MarginAssetDTO> CreateTestMarginAsset()
        {
            string            url            = ApiPaths.MARGIN_ASSET_BASE_PATH;
            MarginAssetEntity templateEntity = EnumerableUtils.PickRandom(AllMarginAssetsFromDB);
            MarginAssetDTO    createDTO      = this.mapper.Map <MarginAssetDTO>(templateEntity);

            createDTO.Id        += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest;
            createDTO.IdIssuer  += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest;
            createDTO.Name      += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest;
            createDTO.Accuracy   = Helpers.Random.Next(2, 8);
            createDTO.DustLimit  = Helpers.Random.NextDouble();
            createDTO.Multiplier = Helpers.Random.NextDouble();
            string createParam = JsonUtils.SerializeObject(createDTO);

            var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, createParam, Method.POST);

            if (response.Status != HttpStatusCode.Created)
            {
                return(null);
            }

            AddOneTimeCleanupAction(async() => await DeleteTestMarginAsset(createDTO.Id));

            return(createDTO);
        }
Beispiel #2
0
        public async Task UpdateMarginAsset()
        {
            string url = ApiPaths.MARGIN_ASSET_BASE_PATH;

            MarginAssetDTO TestMarginAssetUpdate = await CreateTestMarginAsset();

            MarginAssetDTO updateDTO = new MarginAssetDTO()
            {
                Id         = TestMarginAssetUpdate.Id,
                Name       = TestMarginAssetUpdate.Name,
                IdIssuer   = TestMarginAssetUpdate.IdIssuer,
                Symbol     = TestMarginAssetUpdate.Symbol,
                Accuracy   = Helpers.Random.Next(2, 8),
                DustLimit  = Helpers.Random.NextDouble(),
                Multiplier = Helpers.Random.NextDouble()
            };

            string updateParam = JsonUtils.SerializeObject(updateDTO);
            var    response    = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, updateParam, Method.PUT);

            Assert.True(response.Status == HttpStatusCode.NoContent);

            MarginAssetEntity entity = await this.MarginAssetManager.TryGetAsync(updateDTO.Id) as MarginAssetEntity;

            Assert.NotNull(entity);
            entity.ShouldBeEquivalentTo(updateDTO, o => o.ExcludingMissingMembers());
        }
Beispiel #3
0
        public async Task CreateMarginAsset()
        {
            MarginAssetDTO createdDTO = await this.CreateTestMarginAsset();

            Assert.NotNull(createdDTO);

            MarginAssetEntity entity = await this.MarginAssetManager.TryGetAsync(createdDTO.Id) as MarginAssetEntity;

            Assert.NotNull(entity);
            entity.ShouldBeEquivalentTo(createdDTO, o => o.ExcludingMissingMembers());
        }
Beispiel #4
0
        public async Task DeleteMarginAsset()
        {
            MarginAssetDTO TestMarginAssetDelete = await CreateTestMarginAsset();

            string url      = ApiPaths.MARGIN_ASSET_BASE_PATH + "/" + TestMarginAssetDelete.Id;
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.DELETE);

            Assert.True(response.Status == HttpStatusCode.NoContent);

            MarginAssetEntity entity = await this.MarginAssetManager.TryGetAsync(TestMarginAssetDelete.Id) as MarginAssetEntity;

            Assert.Null(entity);
        }