public async void GetAllItemsSuccess()
        {
            var item = new DatabaseModel.RakeItem("assetId12311", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode.Id);
            var item2 = new DatabaseModel.RakeItem("assetId12344", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);
            var item3 = new DatabaseModel.RakeItem("assetId12333", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);

            var list = new List <DatabaseModel.RakeItem>
            {
                item,
                item2,
                item3
            };

            await _rakeItemRepoService.InsertAsync(list);

            var res = await _rakeItemRepoService.GetAll();

            int matches = 0;

            foreach (var t in res)
            {
                matches += list.Count(t1 => t1.AssetId == t.AssetId);
            }

            Assert.Equal(3, matches);
        }
        public async void GetRakeItemsForSpecificMatch()
        {
            var item = new DatabaseModel.RakeItem("assetId15311", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match2.Id,
                                                  _setup.GameMode.Id);
            var item2 = new DatabaseModel.RakeItem("assetId15344", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match2.Id,
                                                   _setup.GameMode.Id);
            var item3 = new DatabaseModel.RakeItem("assetId15333", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match2.Id,
                                                   _setup.GameMode.Id);
            var item4 = new DatabaseModel.RakeItem("assetId1233489", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);

            var list = new List <DatabaseModel.RakeItem>
            {
                item,
                item2,
                item3,
                item4
            };

            await _rakeItemRepoService.InsertAsync(list);

            var res = await _rakeItemRepoService.FindAsync(_setup.Match2);

            Assert.Equal(3, res.Count);
        }
        public async void InsertSameAssetIdButDiffrentDescriptionIdSuccess()
        {
            var item = new DatabaseModel.RakeItem("assetId100", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode.Id);
            var item2 = new DatabaseModel.RakeItem("assetId100", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);
            await _rakeItemRepoService.InsertAsync(new List <DatabaseModel.RakeItem>
            {
                item,
                item2
            });

            var itemResult1 = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "AssetId100",
                DescriptionId = _setup.ItemDescription1.Id,
            });

            var itemResult2 = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "AssetId100",
                DescriptionId = _setup.ItemDescription2.Id,
            });

            Assert.False(itemResult1.Id == itemResult2.Id);
            Assert.NotNull(itemResult1);
            Assert.NotNull(itemResult2);
        }
        public async void FindRakeItemFromGameModeId()
        {
            var item = new DatabaseModel.RakeItem("randAssetId225", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode4.Id);
            var item2 = new DatabaseModel.RakeItem("randAssetId326", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode4.Id);
            var item7 = new DatabaseModel.RakeItem("randAssetI3127", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode4.Id);
            var item8 = new DatabaseModel.RakeItem("randAssetI5427", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode2.Id);
            var item9 = new DatabaseModel.RakeItem("455465427", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode3.Id);

            await _rakeItemRepoService.InsertAsync(new List <DatabaseModel.RakeItem>
            {
                item,
                item2,
                item7,
                item8,
                item9,
            });


            var item1Res = await _rakeItemRepoService.FindFromGameModeIdAsync(new List <int>
            {
                _setup.GameMode4.Id,
                _setup.GameMode2.Id,
            });

            Assert.Equal(4, item1Res.Count);
        }
        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);
        }
        public async void SetRakeItemsAsSold()
        {
            var item = new DatabaseModel.RakeItem("randAssetId125", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                  _setup.GameMode.Id);
            var item2 = new DatabaseModel.RakeItem("randAssetId126", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);
            var item7 = new DatabaseModel.RakeItem("randAssetId127", _setup.ItemDescription1.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                   _setup.GameMode.Id);

            Assert.False(item.IsSold);
            Assert.False(item2.IsSold);

            await _rakeItemRepoService.InsertAsync(new List <DatabaseModel.RakeItem>
            {
                item,
                item2,
                item7
            });

            await _rakeItemRepoService.SetAsSold(new List <string>
            {
                "randAssetId126",
                "randAssetId125",
            });

            var item1Res = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "randAssetId126",
                DescriptionId = _setup.ItemDescription1.Id,
            });

            var item2Res = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "randAssetId125",
                DescriptionId = _setup.ItemDescription2.Id,
            });

            var item7Res = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "randAssetId127",
                DescriptionId = _setup.ItemDescription1.Id,
            });

            Assert.True(item1Res.IsSold);
            Assert.True(item2Res.IsSold);
            Assert.False(item7Res.IsSold);
        }
Exemplo n.º 7
0
        public async Task <DatabaseModel.RakeItem> InsertAsync(DatabaseModel.RakeItem rakeItem)
        {
            var query = _rakeItemQueries.InsertReturnsId(rakeItem);
            var id    = (int)await _databaseConnection.ExecuteScalarAsync(query);

            return(new DatabaseModel.RakeItem
                   (
                       rakeItem.AssetId,
                       rakeItem.DescriptionId,
                       rakeItem.LocationId,
                       rakeItem.Received,
                       rakeItem.MatchId,
                       rakeItem.GameModeId,
                       rakeItem.IsSold,
                       id
                   ));
        }
Exemplo n.º 8
0
        public SqlQuery InsertReturnsId(DatabaseModel.RakeItem rakeItem)
        {
            var dict = new Dictionary <string, object>
            {
                { "@assetId", rakeItem.AssetId },
                { "@descId", rakeItem.DescriptionId },
                { "@locId", rakeItem.LocationId },
                { "@created", rakeItem.Received },
                { "@matchId", rakeItem.MatchId },
                { "@isSold", rakeItem.IsSold },
                { "@gameModeId", rakeItem.GameModeId },
            };

            var queryStr =
                "INSERT INTO [RakeItem] (AssetId, DescriptionId, LocationId, MatchId,Received, IsSold, GameModeId) OUTPUT INSERTED.Id VALUES (@assetId ,@descId, @locId,@matchId, @created,@isSold,@gameModeId)";

            return(new SqlQuery(queryStr, dict));
        }
        public async void AddAndFindSuccess()
        {
            var item =
                new DatabaseModel.RakeItem("assetId78789", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                           _setup.GameMode.Id);
            var itemInsertRes = await _rakeItemRepoService.InsertAsync(item);

            var findRes = await _rakeItemRepoService.FindAsync(new AssetAndDescriptionId
            {
                AssetId       = "assetId78789",
                DescriptionId = _setup.ItemDescription2.Id,
            });

            Assert.True(itemInsertRes.Id > 0);
            Assert.Equal("assetId78789", findRes.AssetId);
            Assert.Equal(_setup.ItemDescription2.Id, findRes.DescriptionId);
            Assert.Equal(_setup.Match1.Id, findRes.MatchId);
            Assert.Equal(DateTime.Today, findRes.Received);
        }
        public async void AddItemWithSameAssetIdMultipleTimesThrows()
        {
            var exceptionAsync = Record.ExceptionAsync(async() =>
            {
                var item = new DatabaseModel.RakeItem("assetId3", _setup.ItemDescription2.Id, _setup.Bot1.Id, DateTime.Today, _setup.Match1.Id,
                                                      _setup.GameMode.Id);
                await _rakeItemRepoService.InsertAsync(new List <DatabaseModel.RakeItem>
                {
                    item,
                    item
                });
            });

            if (exceptionAsync == null)
            {
                Assert.True(false, "No exception was thrown");
            }
            var exception1 = await exceptionAsync;

            Assert.IsType(typeof(SqlException), exception1);
        }
Exemplo n.º 11
0
 public SqlQuery Insert(DatabaseModel.RakeItem rakeItem)
 {
     return(InsertRange(new List <DatabaseModel.RakeItem> {
         rakeItem
     }));
 }