public void TestFluentSymbolUsesLocaleRules() { var lt = new MessageContext("lt"); var us = new MessageContext(new string[] { "en-US", "en" }); var one = new FluentSymbol("one"); var few = new FluentSymbol("few"); var many = new FluentSymbol("many"); var other = new FluentSymbol("other"); var num1 = new FluentNumber("1"); var num11 = new FluentNumber("11"); var num2 = new FluentNumber("2"); var num0_6 = new FluentNumber("0.6"); one.Match(lt, num1).Should().BeTrue(); one.Match(lt, num11).Should().BeFalse(); one.Match(lt, num2).Should().BeFalse(); one.Match(lt, num0_6).Should().BeFalse(); one.Match(us, num1).Should().BeTrue(); one.Match(us, num11).Should().BeFalse(); one.Match(us, num2).Should().BeFalse(); one.Match(us, num0_6).Should().BeFalse(); few.Match(lt, num1).Should().BeFalse(); few.Match(lt, num11).Should().BeFalse(); few.Match(lt, num2).Should().BeTrue(); few.Match(lt, num0_6).Should().BeFalse(); few.Match(us, num1).Should().BeFalse(); few.Match(us, num11).Should().BeFalse(); few.Match(us, num2).Should().BeFalse(); few.Match(us, num0_6).Should().BeFalse(); many.Match(lt, num1).Should().BeFalse(); many.Match(lt, num11).Should().BeFalse(); many.Match(lt, num2).Should().BeFalse(); many.Match(lt, num0_6).Should().BeTrue(); many.Match(us, num1).Should().BeFalse(); many.Match(us, num11).Should().BeFalse(); many.Match(us, num2).Should().BeFalse(); many.Match(us, num0_6).Should().BeFalse(); other.Match(lt, num1).Should().BeFalse(); other.Match(lt, num11).Should().BeTrue(); other.Match(lt, num2).Should().BeFalse(); other.Match(lt, num0_6).Should().BeFalse(); other.Match(lt, num1).Should().BeFalse(); other.Match(us, num11).Should().BeTrue(); other.Match(us, num2).Should().BeTrue(); other.Match(us, num0_6).Should().BeTrue(); }
public void TestFluentSymbol() { var symbol = new FluentSymbol("sym"); var ctx = new MessageContext("en-US"); symbol.Format(ctx).Should().Be("sym"); symbol.Match(ctx, new FluentSymbol("sym")).Should().BeTrue(); symbol.Match(ctx, new FluentSymbol("notsym")).Should().BeFalse(); symbol.Match(ctx, "sym").Should().BeTrue(); symbol.Match(ctx, "notsym").Should().BeFalse(); symbol.Match(ctx, new FluentString("sym")).Should().BeTrue(); symbol.Match(ctx, new FluentString("notsym")).Should().BeFalse(); symbol.Match(ctx, 442).Should().BeFalse(); }