예제 #1
0
        public void TestPostBuilding()
        {
            Building a = new Building()
            {
                BuildingId = "1",
                Name       = "Building1",
                Address    = "Address",
                Admin      = "1"
            };

            var mockBuildingValidator = new Mock <IBuildingValidator>();

            mockBuildingValidator.Setup(x => x.PostBuilding(a)).Verifiable();
            mockBuildingValidator.Setup(x => x.secure(null)).Verifiable();
            mockBuildingValidator.Setup(x => x.AtmSecure(null)).Verifiable();

            var controller        = new BuildingsController(mockBuildingValidator.Object);
            var controllerContext = new HttpControllerContext();
            var request           = new HttpRequestMessage();

            request.Headers.Add("TODO_PAGOS_TOKEN", "1");
            controllerContext.Request    = request;
            controller.ControllerContext = controllerContext;

            IHttpActionResult actionResult = controller.PostBuilding(a);
            var contentResult = actionResult as OkNegotiatedContentResult <IEnumerable <Building> >;

            Assert.IsNotNull(actionResult);
        }