Final code cleanup

This commit is contained in:
JustArchi
2020-11-14 22:37:00 +01:00
parent ea1429a209
commit e82560259b
56 changed files with 2176 additions and 1428 deletions

View File

@@ -32,7 +32,7 @@ namespace ArchiSteamFarm.Tests {
public void MoreCardsThanNeeded() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID),
CreateCard(1, appID),
CreateCard(2, appID),
@@ -41,7 +41,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 3), 1 }
@@ -54,7 +54,7 @@ namespace ArchiSteamFarm.Tests {
public void MultipleSets() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID),
CreateCard(1, appID),
CreateCard(2, appID),
@@ -63,7 +63,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 2 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 2 }
};
@@ -75,7 +75,7 @@ namespace ArchiSteamFarm.Tests {
public void MultipleSetsDifferentAmount() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, 2),
CreateCard(2, appID),
CreateCard(2, appID)
@@ -83,7 +83,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 2 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 2 }
};
@@ -95,7 +95,7 @@ namespace ArchiSteamFarm.Tests {
public void MutliRarityAndType() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, type: Steam.Asset.EType.TradingCard, rarity: Steam.Asset.ERarity.Common),
CreateCard(2, appID, type: Steam.Asset.EType.TradingCard, rarity: Steam.Asset.ERarity.Common),
@@ -121,7 +121,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 2 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 2 },
{ (appID, Steam.Asset.SteamCommunityContextID, 3), 3 },
@@ -136,14 +136,14 @@ namespace ArchiSteamFarm.Tests {
public void NotAllCardsPresent() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID),
CreateCard(2, appID)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint>(0);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new(0);
AssertResultMatchesExpectation(expectedResult, itemsToSend);
}
@@ -151,14 +151,14 @@ namespace ArchiSteamFarm.Tests {
public void OneSet() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID),
CreateCard(2, appID)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 1 }
};
@@ -171,7 +171,7 @@ namespace ArchiSteamFarm.Tests {
const uint appID0 = 42;
const uint appID1 = 43;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID0),
CreateCard(1, appID1)
};
@@ -183,7 +183,7 @@ namespace ArchiSteamFarm.Tests {
}
);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID0, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID1, Steam.Asset.SteamCommunityContextID, 1), 1 }
};
@@ -196,7 +196,7 @@ namespace ArchiSteamFarm.Tests {
const uint appID0 = 42;
const uint appID1 = 43;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID0),
CreateCard(1, appID1)
};
@@ -208,7 +208,7 @@ namespace ArchiSteamFarm.Tests {
}
);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint>(0);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new(0);
AssertResultMatchesExpectation(expectedResult, itemsToSend);
}
@@ -219,7 +219,7 @@ namespace ArchiSteamFarm.Tests {
const uint appID1 = 43;
const uint appID2 = 44;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID0),
CreateCard(2, appID0),
@@ -236,7 +236,7 @@ namespace ArchiSteamFarm.Tests {
}
);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID1, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID1, Steam.Asset.SteamCommunityContextID, 2), 1 },
{ (appID1, Steam.Asset.SteamCommunityContextID, 3), 1 }
@@ -249,14 +249,14 @@ namespace ArchiSteamFarm.Tests {
public void OtherRarityFullSets() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Common),
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Rare)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 1, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 2 }
};
@@ -267,14 +267,14 @@ namespace ArchiSteamFarm.Tests {
public void OtherRarityNoSets() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Common),
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Rare)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint>(0);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new(0);
AssertResultMatchesExpectation(expectedResult, itemsToSend);
}
@@ -283,7 +283,7 @@ namespace ArchiSteamFarm.Tests {
public void OtherRarityOneSet() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Common),
CreateCard(2, appID, rarity: Steam.Asset.ERarity.Common),
CreateCard(1, appID, rarity: Steam.Asset.ERarity.Uncommon),
@@ -293,7 +293,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 3), 1 }
@@ -306,14 +306,14 @@ namespace ArchiSteamFarm.Tests {
public void OtherTypeFullSets() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, type: Steam.Asset.EType.TradingCard),
CreateCard(1, appID, type: Steam.Asset.EType.FoilTradingCard)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 1, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 2 }
};
@@ -324,14 +324,14 @@ namespace ArchiSteamFarm.Tests {
public void OtherTypeNoSets() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, type: Steam.Asset.EType.TradingCard),
CreateCard(1, appID, type: Steam.Asset.EType.FoilTradingCard)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint>(0);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new(0);
AssertResultMatchesExpectation(expectedResult, itemsToSend);
}
@@ -340,7 +340,7 @@ namespace ArchiSteamFarm.Tests {
public void OtherTypeOneSet() {
const uint appID = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID, type: Steam.Asset.EType.TradingCard),
CreateCard(2, appID, type: Steam.Asset.EType.TradingCard),
CreateCard(1, appID, type: Steam.Asset.EType.FoilTradingCard),
@@ -350,7 +350,7 @@ namespace ArchiSteamFarm.Tests {
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 3, appID);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 2), 1 },
{ (appID, Steam.Asset.SteamCommunityContextID, 3), 1 }
@@ -363,14 +363,14 @@ namespace ArchiSteamFarm.Tests {
public void TooHighAmount() {
const uint appID0 = 42;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID0, 2),
CreateCard(2, appID0)
};
HashSet<Steam.Asset> itemsToSend = GetItemsForFullBadge(items, 2, appID0);
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> {
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult = new() {
{ (appID0, Steam.Asset.SteamCommunityContextID, 1), 1 },
{ (appID0, Steam.Asset.SteamCommunityContextID, 2), 1 }
};
@@ -385,7 +385,7 @@ namespace ArchiSteamFarm.Tests {
const uint appID1 = 43;
const uint appID2 = 44;
HashSet<Steam.Asset> items = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> items = new() {
CreateCard(1, appID0),
CreateCard(2, appID0),
CreateCard(3, appID0),
@@ -404,8 +404,12 @@ namespace ArchiSteamFarm.Tests {
}
private static void AssertResultMatchesExpectation(IReadOnlyDictionary<(uint RealAppID, ulong ContextID, ulong ClassID), uint> expectedResult, IReadOnlyCollection<Steam.Asset> itemsToSend) {
if ((expectedResult == null) || (itemsToSend == null)) {
throw new ArgumentNullException(nameof(expectedResult) + " || " + nameof(itemsToSend));
if (expectedResult == null) {
throw new ArgumentNullException(nameof(expectedResult));
}
if (itemsToSend == null) {
throw new ArgumentNullException(nameof(itemsToSend));
}
Dictionary<(uint RealAppID, ulong ContextID, ulong ClassID), long> realResult = itemsToSend.GroupBy(asset => (asset.RealAppID, asset.ContextID, asset.ClassID)).ToDictionary(group => group.Key, group => group.Sum(asset => asset.Amount));
@@ -413,7 +417,7 @@ namespace ArchiSteamFarm.Tests {
Assert.IsTrue(expectedResult.All(expectation => realResult.TryGetValue(expectation.Key, out long reality) && (expectation.Value == reality)));
}
private static Steam.Asset CreateCard(ulong classID, uint realAppID, uint amount = 1, Steam.Asset.EType type = Steam.Asset.EType.TradingCard, Steam.Asset.ERarity rarity = Steam.Asset.ERarity.Common) => new Steam.Asset(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, realAppID: realAppID, type: type, rarity: rarity);
private static Steam.Asset CreateCard(ulong classID, uint realAppID, uint amount = 1, Steam.Asset.EType type = Steam.Asset.EType.TradingCard, Steam.Asset.ERarity rarity = Steam.Asset.ERarity.Common) => new(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, realAppID: realAppID, type: type, rarity: rarity);
private static HashSet<Steam.Asset> GetItemsForFullBadge(IReadOnlyCollection<Steam.Asset> inventory, byte cardsPerSet, uint appID) => GetItemsForFullBadge(inventory, new Dictionary<uint, byte> { { appID, cardsPerSet } });

View File

@@ -29,42 +29,42 @@ namespace ArchiSteamFarm.Tests {
public sealed class Trading {
[TestMethod]
public void MismatchRarityIsNotFair() {
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1, rarity: Steam.Asset.ERarity.Rare) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1, rarity: Steam.Asset.ERarity.Rare) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MismatchRealAppIDsIsNotFair() {
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1, realAppID: 570) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1, realAppID: 570) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MismatchTypesIsNotFair() {
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1, type: Steam.Asset.EType.Emoticon) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1, type: Steam.Asset.EType.Emoticon) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
}
[TestMethod]
public void MultiGameMultiTypeBadReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 9),
CreateItem(3, 9, 730, Steam.Asset.EType.Emoticon),
CreateItem(4, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(4, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(3, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
@@ -75,17 +75,17 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void MultiGameMultiTypeNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 9),
CreateItem(3, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(3, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(4, realAppID: 730, type: Steam.Asset.EType.Emoticon)
};
@@ -96,18 +96,18 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void MultiGameSingleTypeBadReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 9),
CreateItem(3, realAppID: 730),
CreateItem(4, realAppID: 730)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(3, realAppID: 730)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(4, realAppID: 730)
};
@@ -118,17 +118,17 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void MultiGameSingleTypeNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 2),
CreateItem(3, realAppID: 730)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(3, realAppID: 730)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(4, realAppID: 730)
};
@@ -139,7 +139,7 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameAbrynosWasWrongNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2, 2),
CreateItem(3),
@@ -147,11 +147,11 @@ namespace ArchiSteamFarm.Tests {
CreateItem(5)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(2)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(3)
};
@@ -161,15 +161,15 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameDonationAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(3, type: Steam.Asset.EType.SteamGems)
};
@@ -180,18 +180,18 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameMultiTypeBadReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 9),
CreateItem(3, 9, type: Steam.Asset.EType.Emoticon),
CreateItem(4, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(4, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(3, type: Steam.Asset.EType.Emoticon)
};
@@ -202,17 +202,17 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameMultiTypeNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 9),
CreateItem(3, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(3, type: Steam.Asset.EType.Emoticon)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(2),
CreateItem(4, type: Steam.Asset.EType.Emoticon)
};
@@ -223,19 +223,19 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameQuantityBadReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2),
CreateItem(3)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(2),
CreateItem(3)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(4, 3) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(4, 3) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -243,17 +243,17 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameQuantityBadReject2() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2, 2)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(2, 2)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(3, 3) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(3, 3) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -261,17 +261,17 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameQuantityNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 2),
CreateItem(2)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(1),
CreateItem(2)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(3, 2) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(3, 2) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -279,13 +279,13 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeBadReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -293,15 +293,15 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeBadWithOverpayingReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 2),
CreateItem(2, 2),
CreateItem(3, 2)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(1),
CreateItem(3)
};
@@ -312,14 +312,14 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeBigDifferenceAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2, 5),
CreateItem(3)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(3) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(3) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -327,7 +327,7 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeBigDifferenceReject() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1),
CreateItem(2, 2),
CreateItem(3, 2),
@@ -335,12 +335,12 @@ namespace ArchiSteamFarm.Tests {
CreateItem(5, 10)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToGive = new() {
CreateItem(2),
CreateItem(5)
};
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(3),
CreateItem(4)
};
@@ -351,9 +351,9 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeGoodAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> { CreateItem(1, 2) };
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> inventory = new() { CreateItem(1, 2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -361,9 +361,9 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeNeutralAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> { CreateItem(1) };
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> inventory = new() { CreateItem(1) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(1) };
HashSet<Steam.Asset> itemsToReceive = new() { CreateItem(2) };
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
@@ -371,14 +371,14 @@ namespace ArchiSteamFarm.Tests {
[TestMethod]
public void SingleGameSingleTypeNeutralWithOverpayingAccept() {
HashSet<Steam.Asset> inventory = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> inventory = new() {
CreateItem(1, 2),
CreateItem(2, 2)
};
HashSet<Steam.Asset> itemsToGive = new HashSet<Steam.Asset> { CreateItem(2) };
HashSet<Steam.Asset> itemsToGive = new() { CreateItem(2) };
HashSet<Steam.Asset> itemsToReceive = new HashSet<Steam.Asset> {
HashSet<Steam.Asset> itemsToReceive = new() {
CreateItem(1),
CreateItem(3)
};
@@ -387,6 +387,6 @@ namespace ArchiSteamFarm.Tests {
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
}
private static Steam.Asset CreateItem(ulong classID, uint amount = 1, uint realAppID = Steam.Asset.SteamAppID, Steam.Asset.EType type = Steam.Asset.EType.TradingCard, Steam.Asset.ERarity rarity = Steam.Asset.ERarity.Common) => new Steam.Asset(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, realAppID: realAppID, type: type, rarity: rarity);
private static Steam.Asset CreateItem(ulong classID, uint amount = 1, uint realAppID = Steam.Asset.SteamAppID, Steam.Asset.EType type = Steam.Asset.EType.TradingCard, Steam.Asset.ERarity rarity = Steam.Asset.ERarity.Common) => new(Steam.Asset.SteamAppID, Steam.Asset.SteamCommunityContextID, classID, amount, realAppID: realAppID, type: type, rarity: rarity);
}
}