예제 #1
0
        public void GetBadRequetOnInvalidModel()
        {
            var ToyController = new ToyController(MockToysRepository);

            ToyController.Request       = new HttpRequestMessage();
            ToyController.Configuration = new HttpConfiguration();
            ToyController.ModelState.AddModelError("Myerror", new Exception());
            HttpResponseMessage expected = ToyController.Post(new Object() as Toy);

            Assert.IsTrue(expected.ToString().Contains("Bad Request"));
        }
예제 #2
0
        public void GetOkMessageOnPost()
        {
            var ToyController = new ToyController(MockToysRepository);

            ToyController.Request       = new HttpRequestMessage();
            ToyController.Configuration = new HttpConfiguration();
            HttpResponseMessage expected = ToyController.Post(new Toy {
                Id = 8, Name = "Millenium Falcoon", Description = "Chewie, we are at home!", Price = 99.99m, AgeRestriction = 100, Company = "Mattel"
            });
            HttpResponseMessage actual = ToyController.Request.CreateResponse(HttpStatusCode.OK);

            Assert.AreEqual(expected.ToString(), actual.ToString());
        }