public void ConvertFrom() { VectorConverter r = new VectorConverter(); object or = r.ConvertFrom("3, 4"); Assert.AreEqual(typeof(Vector), or.GetType()); Assert.AreEqual(new Vector(3, 4), or); or = r.ConvertFrom("-1, -4"); Assert.AreEqual(typeof(Vector), or.GetType()); Assert.AreEqual(new Vector(-1, -4), or); }
public void ConvertFromInvalidSource() { new Action(() => _converter.ConvertFrom(null)).ShouldThrow <NotSupportedException>().WithMessage("*null*"); new Action(() => _converter.ConvertFrom(new object())).ShouldThrow <NotSupportedException>().WithMessage($"*{typeof(object)}*"); }
public void ConvertFrom_size() { VectorConverter r = new VectorConverter(); r.ConvertFrom(new Vector(10, 20)); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { return(VectorConverter.ConvertFrom(reader.Value)); }