Esempio n. 1
0
        public void WriteExpires()
        {
            // Arrange
            string result = null;

            m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>()))
            .Callback <byte[], int, int>((b, i, c) =>
                                         result = Encoding.ASCII.GetString(b, i, c - 2)).Returns(0);

            // Act
            m_builder.WriteExpires(1234567890);

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal(" 1234567890", result);
        }
Esempio n. 2
0
        public void WriteExpires()
        {
            // Arrange
            int extra  = -1;
            int result = -1;

            m_mockBinaryWriter.Setup(writer => writer.Write(It.IsAny <byte[]>(), 0, It.IsAny <int>()))
            .Callback <byte[], int, int>((b, i, c) =>
            {
                extra  = b[4];
                result = BigEndianConverter.GetInt32(b, 24);
            }).Returns(0);
            m_builder.Reset();
            m_builder.WriteOperation(RequestOperation.Set);

            // Act
            m_builder.WriteExpires(123456789);

            // Assert
            m_builder.WriteTo(m_mockBinaryWriter.Object);
            Assert.Equal(0, extra);
            Assert.Equal(123456789, result);
        }