Exemplo n.º 1
0
        public async Task ChangeOwnerOfItemsSuccess()
        {
            var     matchId       = 1;
            decimal rake          = 10;
            var     gameModeId    = 2;
            var     winningUserId = 1337;

            var bets        = new List <DatabaseModel.Bet>();
            var items       = new List <DatabaseModel.ItemBetted>();
            var winningUser = new DatabaseModel.User("steamId", "name", "img", "tradelin", DateTime.Now, DateTime.Now, false, null, winningUserId);

            A.CallTo(() => _fakedRakeService.GetItemsThatWeShouldTake(rake, bets, items, winningUser)).Returns(new RakeService.RakeResult
            {
                ItemIdsToUs = new List <AssetAndDescriptionId>
                {
                    new AssetAndDescriptionId
                    {
                        AssetId       = "1",
                        DescriptionId = 2,
                    }
                },
                ItemIdsToWinner = new List <AssetAndDescriptionId>
                {
                    new AssetAndDescriptionId
                    {
                        AssetId       = "2",
                        DescriptionId = 2,
                    },
                    new AssetAndDescriptionId
                    {
                        AssetId       = "3",
                        DescriptionId = 2,
                    },
                    new AssetAndDescriptionId
                    {
                        AssetId       = "4",
                        DescriptionId = 2,
                    },
                }
            });

            A.CallTo(() => _fakedItemRepoService.FindAsync(A <List <AssetAndDescriptionId> > ._)).Returns(new List <DatabaseModel.Item>
            {
                new DatabaseModel.Item("1", 2, 3, 5, DateTimeOffset.Now)
            });

            await _service.ChangeOwnerOfItems(bets, items, winningUser, matchId, rake, gameModeId);

            A.CallTo(() => _fakedItemRepoService.ChangeOwner(A <List <AssetAndDescriptionId> > .That.Matches(list => list.Count == 3), winningUser)).MustHaveHappened();

            A.CallTo(() => _fakedRakeItemRepoService.InsertAsync(A <List <DatabaseModel.RakeItem> > .That.Matches(
                                                                     list =>
                                                                     list.Count == 1 &&
                                                                     list[0].AssetId == "1" &&
                                                                     list[0].DescriptionId == 2 &&
                                                                     list[0].GameModeId == gameModeId &&
                                                                     list[0].MatchId == matchId
                                                                     ), null)).MustHaveHappened();

            A.CallTo(() => _fakedRakeItemRepoService.InsertAsync(A <List <DatabaseModel.RakeItem> > .That.Matches(list =>
                                                                                                                  list.Count == 1 &&
                                                                                                                  list[0].AssetId == "1" &&
                                                                                                                  list[0].DescriptionId == 2
                                                                                                                  ), null
                                                                 )).MustHaveHappened();

            A.CallTo(() => _fakedRakeService.GetItemsThatWeShouldTake(rake, bets, items, winningUser)).MustHaveHappened();
        }
        public async void AddItemsSuccess()
        {
            var item = new DatabaseModel.RakeItem("assetId1", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode.Id);
            var itemId = await _rakeItemRepoService.InsertAsync(item);

            var item2 = new DatabaseModel.RakeItem("assetId2", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);
            var itemId2 = await _rakeItemRepoService.InsertAsync(item2);

            Assert.NotEqual(itemId.Id, itemId2.Id);
        }