public void GetItemForDistance(int distance, string result) { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); // Act distanceWeightedItems.AddItem("Item1", new List <DistanceWeightValue>() { new DistanceWeightValue(1, 10), new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 0) }); distanceWeightedItems.AddItem("Item2", new List <DistanceWeightValue>() { new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 5) }); distanceWeightedItems.PrepareForUse(); //Debug.Log(distanceWeightedItems.ToString()); // Assert Assert.AreEqual(result, distanceWeightedItems.GetItemForDistance(distance)); }
public void GetAssociatedItemForDistance(int distance, int result) { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); distanceWeightedItems.AddItem("Item1", new List <DistanceWeightValue>() { new DistanceWeightValue(1, 10), new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 0) }); distanceWeightedItems.AddItem("Item2", new List <DistanceWeightValue>() { new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 5) }); distanceWeightedItems.PrepareForUse(); // Act var associatedDistance = distanceWeightedItems.GetAssociatedDistance(distance).Distance; // Assert Assert.AreEqual(result, associatedDistance); }
public void ItemWithoutWeightsNotAdded() { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); distanceWeightedItems.AddItem("Item", new List <DistanceWeightValue>()); // Assert Assert.AreEqual(0, distanceWeightedItems.ItemCount); }
public void DistancesSavedAndUnique() { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); // Act distanceWeightedItems.AddItem("Item1", new List <DistanceWeightValue>() { new DistanceWeightValue(1, 10), new DistanceWeightValue(2, 10) }); distanceWeightedItems.AddItem("Item2", new List <DistanceWeightValue>() { new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 10) }); // Assert Assert.AreEqual(distanceWeightedItems.GetDistances().Distinct().Count(), distanceWeightedItems.GetDistances().Count); }
public void AllDistancesSavedAndGapsFilled(int distance, int result) { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); // Act distanceWeightedItems.AddItem("Item1", new List <DistanceWeightValue>() { new DistanceWeightValue(1, 10), new DistanceWeightValue(2, 10) }); distanceWeightedItems.AddItem("Item2", new List <DistanceWeightValue>() { new DistanceWeightValue(2, 10), new DistanceWeightValue(4, 5) }); distanceWeightedItems.PrepareForUse(); // Assert Assert.AreEqual(result, distanceWeightedItems.GetDistanceTotalWeight(distance)); }
public void ItemCountLikeItemsAdded(int count) { // Arrange var distanceWeightedItems = new DistanceWeightedItems <string>(); for (var i = 0; i < count; i++) { distanceWeightedItems.AddItem("Item" + i, new List <DistanceWeightValue>() { new DistanceWeightValue(2, 10) }); } // Assert Assert.AreEqual(count, distanceWeightedItems.ItemCount); }