public void ObjectsCanBeAddedByMethod() { var weightBlock = new WeightBlock(); weightBlock.AddObject("new_object", 69); weightBlock.AddObject("new_object2", 5); Assert.Equal((uint)69, weightBlock.GetAbsoluteWeight("new_object")); Assert.Equal((uint)5, weightBlock.GetAbsoluteWeight("new_object2")); Assert.Equal((uint)74, weightBlock.SumOfAbsoluteWeights); Assert.Equal("new_object", weightBlock.GetMatchingObject(0)); Assert.Equal("new_object2", weightBlock.GetMatchingObject(0.95)); }
public void GetMatchingObjectReturnsNullWhenObjectsMapIsEmpty() { var reader = new BufferedReader( "= {}" ); var weightBlock = new WeightBlock(reader); Assert.Null(weightBlock.GetMatchingObject(0.345)); }
public void ObjectsCanBeAdded() { var reader = new BufferedReader( "= {\n" + "\t5 = female_hair_greek_1\n" + "\t2 = female_hair_greek_2\n" + "\t6 = female_hair_greek_3\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Equal((uint)5, weightBlock.GetAbsoluteWeight("female_hair_greek_1")); Assert.Equal((uint)2, weightBlock.GetAbsoluteWeight("female_hair_greek_2")); Assert.Equal((uint)6, weightBlock.GetAbsoluteWeight("female_hair_greek_3")); Assert.Equal((uint)13, weightBlock.SumOfAbsoluteWeights); Assert.Equal("female_hair_greek_1", weightBlock.GetMatchingObject(0.37234234)); Assert.Equal("female_hair_greek_2", weightBlock.GetMatchingObject(0.52234234234)); Assert.Equal("female_hair_greek_3", weightBlock.GetMatchingObject(1)); }
public void GetMatchingObjectThrowsErrorOnArgumentGreaterThan1() { var reader = new BufferedReader( "= {\n" + "\t2 = female_hair_greek_2\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Throws <ArgumentOutOfRangeException>(() => weightBlock.GetMatchingObject(1.234)); }
public void GetMatchingObjectThrowsErrorOnNegativeArgument() { var reader = new BufferedReader( "=\n" + "{\n" + "\t2 = female_hair_greek_2\n" + "}" ); var weightBlock = new WeightBlock(reader); Assert.Throws <ArgumentOutOfRangeException>(() => weightBlock.GetMatchingObject(-0.5)); }