public async Task BuyFutbolPlayerAsync_BuyAlreadyExistingFutbolPlayer_ReturnsException()
        {
            //arrange
            fakePlayFabService.Inventory = new List <PlayFabItemInventory> {
                new PlayFabItemInventory
                {
                    ItemId              = "1",
                    ItemInstanceId      = "1",
                    PurchaseDate        = new System.DateTime(2020, 1, 5, 13, 1, 0),
                    DisplayName         = "Kenneth Johnston",
                    Currency            = fakePlayFabService.Currency,
                    PriceStore          = 4000,
                    CustomDataStore     = "{\"FutbolTeamID\":\"1\",\"Name\":\"Kenneth\",\"LastName\":\"Johnston\",\"Birthdate\":\"2020-02-24T20:07:42.8397804-03:00\",\"Price\":4000,\"Position\":1,\"IsStarter\":false,\"id\":\"1\"}",
                    CustomDataInventory = new CustomDataInventory
                    {
                        IsStarter = false
                    }
                }
            };

            //act
            async Task actual()
            {
                await fantasySoccerService.BuyFutbolPlayerAsync("1", 4000);
            }

            //assert
            await Assert.ThrowsAsync <Exception>(actual);
        }
示例#2
0
        public async Task <ResponseWrapper <string> > Buy(FutbolPlayer futbolPlayer)
        {
            try
            {
                var budget = await fantasySoccerService.BuyFutbolPlayerAsync(futbolPlayer.ID, (int)futbolPlayer.Price);

                return(new ResponseWrapper <string>
                {
                    StatusCode = Models.Responses.StatusCode.OK,
                    Response = budget,
                    Message = $"{futbolPlayer.GetFullName()} was added to your team.",
                });
            }
            catch
            {
                return(new ResponseWrapper <string>
                {
                    StatusCode = Models.Responses.StatusCode.BadRequest,
                    Message = "Couldn't buy the player. \nTry again later"
                });
            }
        }