public void ThenReturnsFalse(string weight1, string weight2, string weight3) { Dictionary <string, IStartingStat> stats = new Dictionary <string, IStartingStat> { { "Money", new StartingStatStub(5, 10, 0) }, { "Health", new StartingStatStub(5, 10, 0) }, { "Power", new StartingStatStub(5, 10, 0) } }; Dictionary <string, float> weights = new Dictionary <string, float>() { { weight1, 0.75f }, { weight2, 0.5f }, { weight3, 0.1f } }; ICardOption cardOptionOne = new CardOptionsStub( "Option One", "Option One Description", new PlayerStatsToChangeStub(new Dictionary <string, int> { { "Money", -2 }, { "Power", 2 }, { "Health", -2 } }), new string[0]); ICardOption cardOptionTwo = new CardOptionsStub( "Option Two", "Option Two Description", new PlayerStatsToChangeStub(new Dictionary <string, int> { { "Money", 2 }, { "Power", 0 - 2 }, { "Health", 2 } }), new string[0]); IStartingStats startingStats = new StartingStatsStub(stats, weights, 2); ICard card = new CardStub(Guid.NewGuid().ToString(), "Card Title", "Card Description", "http://google.com/hello.png", new[] { cardOptionOne, cardOptionTwo }, "Common"); IJsonDeserializeAdaptor adaptorStub = new JsonDeserializeAdaptorStub(card); IValidCardData validCardData = new ValidCardData(adaptorStub, startingStats); Assert.False(validCardData.Execute("This is real json").Valid); Assert.True(validCardData.Execute("This is real json").ErrorMessage.ToLower().Trim() .Contains("invalid weight value")); Assert.True(validCardData.Execute("This is real json").ErrorMessage.ToLower().Trim() .Contains(card.CardID.ToLower())); Assert.IsNull(validCardData.Execute("This is real json").ValidCardData); }
ICardOption[] CreateCardOptions(int count, string[] valueNames) { ICardOption[] options = new ICardOption[count]; for (int i = 0; i < count; i++) { Dictionary <string, int> stats = new Dictionary <string, int>(); for (int j = 0; j < valueNames.Length; j++) { stats.Add(valueNames[j], new Random().Next(-10, 10)); } options[i] = new CardOptionsStub( "Option Two", "Option Two Description", new PlayerStatsToChangeStub(stats), new string[0]); } return(options); }