コード例 #1
0
 public void should_get_count()
 {
     //arrange
     var request = new Request();
     //act
     var res = request.GetRequestCount();
     //assert
     Assert.LessOrEqual(0,res);
 }
コード例 #2
0
 public void should_send_package_with_data()
 {
     //arrange
     var request = new Request();
     string userName = Guid.NewGuid().ToString();
     string userPassword = Guid.NewGuid().ToString();
     //act
     request.Send(userName + userPassword);
     //assert
     Assert.Pass();
 }
コード例 #3
0
        public void should_request_get_request_count()
        {
            //arrange
            Random rand = new Random();
            int expected = rand.Next(10);
            var request = new Request(expected);

            //act
            var res = request.GetRequestCount();

            //assert
            Assert.AreEqual(res, expected);
        }
コード例 #4
0
        public void should_request_send_with_any_string_packet()
        {
            using (StringWriter sw = new StringWriter())
            {
                //arrange
                Console.SetOut(sw);

                var request = new Request(new Random().Next(10));
                int beforeCount = request.GetRequestCount();

                string packet = Guid.NewGuid().ToString();
                string expected = string.Format("Packet data: {0}{1}", packet, Environment.NewLine);

                //act
                request.Send(packet);
                int afterCount = request.GetRequestCount();

                //assert
                Assert.AreEqual(afterCount - beforeCount, 1);
                Assert.AreEqual(expected, sw.ToString());

                //after test
                ConsoleInitialize();
            }
        }