public void GetPriority(Type type, int simulatedConversionCost, int?expectedPriority) { IConverter converter = Mocks.StrictMock <IConverter>(); using (Mocks.Record()) { Expect.Call(converter.GetConversionCost(type, typeof(string))).Return(new ConversionCost(simulatedConversionCost)); } ConvertToStringFormattingRule formattingRule = new ConvertToStringFormattingRule(converter); Assert.AreEqual(expectedPriority, formattingRule.GetPriority(type)); }
[Row("abc\ndef", "{abc\\ndef}")] // note using literal format public void Format(string simulatedConversionResult, string expectedResult) { object value = new object(); IConverter converter = Mocks.StrictMock <IConverter>(); using (Mocks.Record()) { Expect.Call(converter.Convert(value, typeof(string))).Return(simulatedConversionResult); } ConvertToStringFormattingRule formattingRule = new ConvertToStringFormattingRule(converter); Assert.AreEqual(expectedResult, formattingRule.Format(value, Mocks.Stub <IFormatter>())); }