예제 #1
0
        public void CanSendPostRequest()
        {
            //Arrange
            List <ObjectType> orderList = new List <ObjectType>()
            {
                new ObjectType {
                    ObjectID       = 1,
                    ObjectName     = "C# Book",
                    ObjectPrice    = 3,
                    ObjectQuantity = "10 pieces"
                }
            };
            var controller = new DemoWebAPIWithSwagger.Controllers.InvoiceController();

            //Act
            string response = controller.Post(orderList);

            //Assert
            Assert.Equal("Failed to connect to database", response);
        }
예제 #2
0
        public void SentInvalidPostRequest()
        {
            //Arrange
            List <ObjectType> orderList = new List <ObjectType>()
            {
                new ObjectType {
                    ObjectID       = 0,
                    ObjectName     = "C# Book",
                    ObjectPrice    = 3,
                    ObjectQuantity = "10 pieces"
                }
            };
            var controller = new DemoWebAPIWithSwagger.Controllers.InvoiceController();

            //Act
            string response = controller.Post(orderList);

            //Assert
            Assert.Equal("Illegal value for field ObjectID ( should be a number greater than 0 )", response);
        }