public void IResolveManagerIsNullShouldThrow() { MaxLengthFormatter formatter = new MaxLengthFormatter(); Action act = () => formatter.Format("something", "somename", null); act.ShouldThrow <PtvArgumentException>().WithMessage("Resolve manager cannot be null and has to be provided.", "Because resolve manager is used for resolving of other instances."); }
public void FormatValueNameResolveManagerEntityShouldNotThrowNotImplemented() { MaxLengthFormatter formatter = new MaxLengthFormatter(); Action act = () => formatter.Format("something", "somename", null, null); act.ShouldNotThrow <NotImplementedException>(); }
public void FormatValueNameShouldNotThrowNotImplemented() { MaxLengthFormatter formatter = new MaxLengthFormatter(); Action act = () => formatter.Format("something", "somename"); act.ShouldNotThrow <NotImplementedException>(); }
public void TestWithTooLongJson() { MaxLengthFormatter formatter = new MaxLengthFormatter(50); string valueIn = "{\"entityMap\":{},\"blocks\":[{\"text\":\"Toimisto ottaa vastaan asumisoikeusasunnon hakemukset järjestysnumeron saaneilta hakijoilta.\",\"type\":\"unstyled\",\"key\":\"N5A1X\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[]}]}"; Action act = () => formatter.Format(valueIn, "DemoName", new MockResolveManager()); act.ShouldThrowExactly <ArgumentOutOfRangeException>(); }
public void TestWithPlainText() { MaxLengthFormatter formatter = new MaxLengthFormatter(); string valueIn = "some text here"; string valueOut = formatter.Format(valueIn, "DemoName", new MockResolveManager()) as string; // MaxLengthFormatter returns the same string that it was passed so the string references should be the same ReferenceEquals(valueIn, valueOut).Should().BeTrue(); }
public void TestWithJson() { MaxLengthFormatter formatter = new MaxLengthFormatter(500); string valueIn = "{\"entityMap\":{},\"blocks\":[{\"text\":\"Toimisto ottaa vastaan asumisoikeusasunnon hakemukset järjestysnumeron saaneilta hakijoilta.\",\"type\":\"unstyled\",\"key\":\"N5A1X\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[]}]}"; string valueOut = formatter.Format(valueIn, "DemoName", new MockResolveManager()) as string; // MaxLengthFormatter returns the same string that it was passed so the string references should be the same ReferenceEquals(valueIn, valueOut).Should().BeTrue(); }
public void TestWithObject() { // the formatter expects the value to be string MaxLengthFormatter formatter = new MaxLengthFormatter(); SomeDemoObject obj = new SomeDemoObject() { Integer = 100, String = "Some text", Type = "Demo" }; Action act = () => formatter.Format(obj, "Demo", new MockResolveManager()); act.ShouldThrowExactly <PtvArgumentException>($"Expected value is string! Value {obj.ToString()} of type Demo is not valid."); }