2024-03-16 23:06:13 +00:00
|
|
|
// ----------------------------------------------------------------------------------------------
|
2019-02-16 16:34:17 +00:00
|
|
|
// _ _ _ ____ _ _____
|
2017-11-18 16:27:06 +00:00
|
|
|
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
|
|
|
|
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
|
|
|
|
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
|
|
|
|
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
|
2024-03-16 23:06:13 +00:00
|
|
|
// ----------------------------------------------------------------------------------------------
|
2024-03-17 01:35:40 +00:00
|
|
|
// |
|
2024-01-08 10:33:28 +00:00
|
|
|
// Copyright 2015-2024 Łukasz "JustArchi" Domeradzki
|
2018-07-27 02:52:14 +00:00
|
|
|
// Contact: JustArchi@JustArchi.net
|
2024-03-17 01:35:40 +00:00
|
|
|
// |
|
2018-07-27 02:52:14 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2024-03-17 01:35:40 +00:00
|
|
|
// |
|
2018-07-27 02:52:14 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2024-03-17 01:35:40 +00:00
|
|
|
// |
|
2018-07-27 02:52:14 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2017-07-10 06:52:59 +00:00
|
|
|
|
2017-07-10 06:20:15 +00:00
|
|
|
using System.Collections.Generic;
|
2021-05-07 23:37:22 +00:00
|
|
|
using ArchiSteamFarm.Steam.Data;
|
2017-07-10 06:20:15 +00:00
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2021-05-07 23:37:22 +00:00
|
|
|
using static ArchiSteamFarm.Steam.Exchange.Trading;
|
2017-07-10 06:20:15 +00:00
|
|
|
|
2021-11-10 20:23:24 +00:00
|
|
|
namespace ArchiSteamFarm.Tests;
|
|
|
|
|
2024-06-24 22:18:13 +00:00
|
|
|
#pragma warning disable CA1812 // False positive, the class is used during MSTest
|
2021-11-10 20:23:24 +00:00
|
|
|
[TestClass]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal sealed class Trading {
|
2023-01-24 21:55:15 +00:00
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void ExploitingNewSetsIsFairButNotNeutral() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 40),
|
|
|
|
CreateItem(2, amount: 10),
|
|
|
|
CreateItem(3, amount: 10)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2023-01-24 21:55:15 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 5),
|
|
|
|
CreateItem(3, amount: 5)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2023-01-24 21:55:15 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
2023-01-24 21:55:15 +00:00
|
|
|
CreateItem(4)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2023-01-24 21:55:15 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
2024-05-13 07:29:30 +00:00
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void Issue3203() {
|
2024-05-13 07:29:30 +00:00
|
|
|
HashSet<Asset> inventory = [
|
|
|
|
CreateItem(1, amount: 2),
|
|
|
|
CreateItem(2, amount: 6),
|
|
|
|
CreateItem(3),
|
|
|
|
CreateItem(4)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(2, amount: 2)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(5),
|
|
|
|
CreateItem(6),
|
|
|
|
CreateItem(7)
|
|
|
|
];
|
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
2021-11-10 20:23:24 +00:00
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MismatchRarityIsNotFair() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1, rarity: EAssetRarity.Rare)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MismatchRealAppIDsIsNotFair() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1, realAppID: 570)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MismatchTypesIsNotFair() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1, type: EAssetType.Emoticon)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsFalse(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MultiGameMultiTypeBadReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
|
|
|
CreateItem(3, amount: 9, realAppID: 730, type: EAssetType.Emoticon),
|
|
|
|
CreateItem(4, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(4, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(3, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MultiGameMultiTypeNeutralAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
|
|
|
CreateItem(3, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(3, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(4, realAppID: 730, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MultiGameSingleTypeBadReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(3, realAppID: 730),
|
|
|
|
CreateItem(4, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(3, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
|
|
|
CreateItem(4, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void MultiGameSingleTypeNeutralAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 2),
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(3, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(3, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
|
|
|
CreateItem(4, realAppID: 730)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameAbrynosWasWrongNeutralAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 2),
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(3),
|
|
|
|
CreateItem(4),
|
|
|
|
CreateItem(5)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(3)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
2017-07-10 06:20:15 +00:00
|
|
|
}
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameDonationAccept() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> inventory = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(3, type: EAssetType.SteamGems)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameMultiTypeBadReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
|
|
|
CreateItem(3, amount: 9, type: EAssetType.Emoticon),
|
|
|
|
CreateItem(4, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(4, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(3, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameMultiTypeNeutralAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
|
|
|
CreateItem(3, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(3, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(4, type: EAssetType.Emoticon)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameQuantityBadReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(2),
|
|
|
|
CreateItem(3)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(2),
|
|
|
|
CreateItem(3)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(4, amount: 3)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameQuantityBadReject2() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(3, amount: 3)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameQuantityNeutralAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 2),
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(3, amount: 2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeBadReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeBadWithOverpayingReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 2),
|
|
|
|
CreateItem(2, amount: 2),
|
|
|
|
CreateItem(3, amount: 2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(3)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeBigDifferenceAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 5),
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(3)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(3)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeBigDifferenceReject() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(2, amount: 2),
|
|
|
|
CreateItem(3, amount: 2),
|
|
|
|
CreateItem(4, amount: 3),
|
|
|
|
CreateItem(5, amount: 10)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(2),
|
|
|
|
CreateItem(5)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(3),
|
|
|
|
CreateItem(4)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeGoodAccept() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> inventory = [
|
|
|
|
CreateItem(1, amount: 2)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeNeutralAccept() {
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> inventory = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(1)
|
|
|
|
];
|
|
|
|
|
|
|
|
HashSet<Asset> itemsToReceive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void SingleGameSingleTypeNeutralWithOverpayingAccept() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 2),
|
|
|
|
CreateItem(2, amount: 2)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(2)
|
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2021-11-10 20:23:24 +00:00
|
|
|
CreateItem(1),
|
|
|
|
CreateItem(3)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2021-11-10 20:23:24 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
2023-11-14 15:25:40 +00:00
|
|
|
[TestMethod]
|
2024-06-24 22:18:13 +00:00
|
|
|
internal void TakingExcessiveAmountOfSingleCardCanStillBeFairAndNeutral() {
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> inventory = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 52),
|
|
|
|
CreateItem(2, amount: 73),
|
|
|
|
CreateItem(3, amount: 52),
|
|
|
|
CreateItem(4, amount: 47),
|
2023-11-14 15:25:40 +00:00
|
|
|
CreateItem(5)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2023-11-14 15:25:40 +00:00
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
HashSet<Asset> itemsToGive = [
|
|
|
|
CreateItem(2, amount: 73)
|
|
|
|
];
|
2023-11-14 15:25:40 +00:00
|
|
|
|
2023-12-11 22:55:13 +00:00
|
|
|
HashSet<Asset> itemsToReceive = [
|
2024-03-17 01:29:04 +00:00
|
|
|
CreateItem(1, amount: 9),
|
|
|
|
CreateItem(3, amount: 9),
|
|
|
|
CreateItem(4, amount: 8),
|
|
|
|
CreateItem(5, amount: 24),
|
|
|
|
CreateItem(6, amount: 23)
|
2023-12-11 22:55:13 +00:00
|
|
|
];
|
2023-11-14 15:25:40 +00:00
|
|
|
|
|
|
|
Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive));
|
|
|
|
Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive));
|
|
|
|
}
|
|
|
|
|
2024-03-17 01:29:04 +00:00
|
|
|
private static Asset CreateItem(ulong classID, ulong instanceID = 0, uint amount = 1, bool marketable = false, bool tradable = false, uint realAppID = Asset.SteamAppID, EAssetType type = EAssetType.TradingCard, EAssetRarity rarity = EAssetRarity.Common) => new(Asset.SteamAppID, Asset.SteamCommunityContextID, classID, amount, new InventoryDescription(Asset.SteamAppID, classID, instanceID, marketable, tradable, realAppID, type, rarity));
|
2018-07-27 02:52:14 +00:00
|
|
|
}
|
2024-06-24 22:18:13 +00:00
|
|
|
#pragma warning restore CA1812 // False positive, the class is used during MSTest
|