Пример #1
0
        public void Indexer_Get_ReturnsMatchingParserForType()
        {
            var stringParser = new BStringParser();
            var list         = new BObjectParserList {
                stringParser
            };

            var parser = list[typeof(BString)];

            parser.Should().BeSameAs(stringParser);
        }
Пример #2
0
        public void Get_Generic_ReturnsMatchingParser()
        {
            var stringParser = new BStringParser();
            var list         = new BObjectParserList {
                stringParser
            };

            var parser = list.Get <BString>();

            parser.Should().BeSameAs(stringParser);
        }
Пример #3
0
        public void Indexer_Set_AddsParserForType()
        {
            var stringParser = new BStringParser();

            var list = new BObjectParserList();

            list[typeof(BString)] = stringParser;

            list.Should().HaveCount(1);
            list[typeof(BString)].Should().BeSameAs(stringParser);
        }
Пример #4
0
        public void CanParseEncodedAsLatin1()
        {
            var encoding = Encoding.GetEncoding("LATIN1");
            var expected = new BString("æøå", encoding);
            var parser   = new BStringParser(encoding);

            // "3:æøå"
            var bytes   = new byte[] { 51, 58, 230, 248, 229 };
            var bstring = parser.Parse(bytes);

            bstring.Should().Be(expected);
        }
Пример #5
0
        public void Indexer_Set_ReplacesExistingParserForType()
        {
            var stringParser1 = new BStringParser();
            var stringParser2 = new BStringParser();
            var list          = new BObjectParserList {
                stringParser1
            };

            list[typeof(BString)] = stringParser2;

            list.Should().HaveCount(1);
            list[typeof(BString)].Should().BeSameAs(stringParser2);
        }
        public async Task CanParseEncodedAsLatin1Async()
        {
            var encoding = Encoding.GetEncoding("LATIN1");
            var expected = new BString("æøå", encoding);
            var parser   = new BStringParser(encoding);

            // "3:æøå"
            var bytes = new byte[] { 51, 58, 230, 248, 229 };

            var(reader, writer) = new Pipe();
            await writer.WriteAsync(bytes);

            var bstring = await parser.ParseAsync(reader);

            bstring.Should().Be(expected);
            bstring.GetSizeInBytes().Should().Be(5);
        }
Пример #7
0
 public BStringParserTests()
 {
     Parser = new BStringParser();
 }
Пример #8
0
        public void Get_Generic_ReturnsMatchingParser()
        {
            var stringParser = new BStringParser();
            var list = new BObjectParserList {stringParser};

            var parser = list.Get<BString>();

            parser.Should().BeSameAs(stringParser);
        }
Пример #9
0
        public void Indexer_Set_ReplacesExistingParserForType()
        {
            var stringParser1 = new BStringParser();
            var stringParser2 = new BStringParser();
            var list = new BObjectParserList { stringParser1 };

            list[typeof (BString)] = stringParser2;

            list.Should().HaveCount(1);
            list[typeof (BString)].Should().BeSameAs(stringParser2);
        }
Пример #10
0
        public void Indexer_Set_AddsParserForType()
        {
            var stringParser = new BStringParser();

            var list = new BObjectParserList();
            list[typeof (BString)] = stringParser;

            list.Should().HaveCount(1);
            list[typeof (BString)].Should().BeSameAs(stringParser);
        }
Пример #11
0
        public void Indexer_Get_ReturnsMatchingParserForType()
        {
            var stringParser = new BStringParser();
            var list = new BObjectParserList {stringParser};

            var parser = list[typeof(BString)];

            parser.Should().BeSameAs(stringParser);
        }