Пример #1
0
        public void ReadTestPositive()
        {
            MockRemoteClient client = new MockRemoteClient("http://www.contoso1234.com:8080/letters/readme.html");

            Assert.IsNotNull(client);
            MemoryStream stream     = new MemoryStream();
            string       mockString = "This is a mock response";

            byte[] buffer = ASCIIEncoding.ASCII.GetBytes(mockString);
            stream.Write(buffer, 0, buffer.Length);
            stream.Seek(0, SeekOrigin.Begin);
            client.SetupTestData(stream);
            MemoryStream readData = new MemoryStream();
            int          countRead;

            byte[] readBytes = new byte[4];
            while ((countRead = client.Read(readBytes, 0, 4)) > 0)
            {
                readData.Write(readBytes, 0, countRead);
            }
            readData.Seek(0, SeekOrigin.Begin);
            StreamReader reader = new StreamReader(readData, ASCIIEncoding.ASCII);

            Assert.AreEqual(mockString, reader.ReadToEnd());
        }
Пример #2
0
        public void ConstructionTestInvalidAddressNegative()
        {
            MockRemoteClient client = new MockRemoteClient("htt1://www.contoso1234.com:8080/letters/readme.html");

            Assert.IsNotNull(client);
            MemoryStream stream = new MemoryStream();

            byte[] buffer = System.Text.ASCIIEncoding.ASCII.GetBytes("This is a mock response");
            stream.Write(buffer, 0, buffer.Length);
            client.SetupTestData(stream);
        }