public void DeleteTenantDeletesTenant()
        {
            //Arrange:
            // Instantiate TenantsController so its methods can be called
            // Create a new tenant to be deleted, and get its tenant ID
            var tenantController = new TenantsController();

            var tenant = new TenantModel
            {
                FirstName = "Testy",
                LastName = "Testering",
                Telephone = "555-1212",
                EmailAddress = "*****@*****.**"
            };
            IHttpActionResult result = tenantController.PostTenant(tenant);
            CreatedAtRouteNegotiatedContentResult<TenantModel> contentResult =
                (CreatedAtRouteNegotiatedContentResult<TenantModel>)result;

            int tenantIdToDelete = contentResult.Content.TenantId;

            // Add a lease corresponding to the tenant
            int createdLeaseId;
            using (var leaseController = new LeasesController())
            {
                var lease = new LeaseModel
                {
                    CreatedDate = new DateTime(2014, 9, 30),
                    PropertyId = 1,
                    TenantId = tenantIdToDelete,
                    StartDate = new DateTime(2015, 1, 30),
                    Rent = 800,
                    LeaseType = Constants.RentPeriod.Monthly
                };
                IHttpActionResult leaseResult = leaseController.PostLease(lease);
                CreatedAtRouteNegotiatedContentResult<LeaseModel> leaseContentResult =
                    (CreatedAtRouteNegotiatedContentResult<LeaseModel>)leaseResult;

                createdLeaseId = leaseContentResult.Content.LeaseId;
            }

            //Act: Call DeleteTenant
            result = tenantController.DeleteTenant(tenantIdToDelete);

            //Assert:
            // Verify that HTTP result is OK
            // Verify that reading deleted tenant returns result not found
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<TenantModel>));

            result = tenantController.GetTenant(tenantIdToDelete);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));

            // Verify that the lease created above was deleted
            using (var leaseController = new LeasesController())
            {
                IHttpActionResult leaseResult = leaseController.GetLease(createdLeaseId);
                Assert.IsInstanceOfType(leaseResult, typeof(NotFoundResult));
            }
        }
        [TestMethod] // [4] Delete Tenant
        public void DeletePropertyDeleteProperty()
        {
            //Arrange
            var tctrl = new TenantsController();

            //Act
            var newTenant = new TenantModel
            {
                FirstName = "Test",
                LastName = "LastNameTest",
                Telephone = "12223334444",
                EmailAddress = "*****@*****.**"
            };

            //Add 'new tenant' to database using post
            //save returned value as result
            IHttpActionResult result = tctrl.PostTenant(newTenant);

            //Cast result as content result so I can gather intel on it
            CreatedAtRouteNegotiatedContentResult<TenantModel> contentResult = (CreatedAtRouteNegotiatedContentResult<TenantModel>)result;

            //Result contains the property I had just created 
            result = tctrl.GetTenant(contentResult.Content.TenantId);

            //get tenantmodel from result
            OkNegotiatedContentResult<TenantModel> tenantResult = (OkNegotiatedContentResult<TenantModel>)result;

            //Act
            result = tctrl.DeleteTenant(contentResult.Content.TenantId);

            //Assert
            //If action returns not found
            Assert.IsNotInstanceOfType(result, typeof(NotFoundResult));

            //If action retruns OK()
            Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<TenantModel>));


        }
        public void PostTenantCreatesTenant()
        {
            //Arrange: Instantiate TenantsController so its methods can be called
            var tenantController = new TenantsController();

            //Act:
            // Create a TenantModel object populated with test data,
            //  and call PostTenant
            var newTenant = new TenantModel
            {
                FirstName = "Testy",
                LastName = "McTest",
                Telephone = "555-1212",
                EmailAddress = "*****@*****.**"
            };
            IHttpActionResult result = tenantController.PostTenant(newTenant);

            //Assert:
            // Verify that the HTTP result is CreatedAtRouteNegotiatedContentResult
            // Verify that the HTTP result body contains a nonzero tenant ID
            Assert.IsInstanceOfType
                (result, typeof(CreatedAtRouteNegotiatedContentResult<TenantModel>));
            CreatedAtRouteNegotiatedContentResult<TenantModel> contentResult =
                (CreatedAtRouteNegotiatedContentResult<TenantModel>)result;
            Assert.IsTrue(contentResult.Content.TenantId != 0);

            // Delete the test tenant
            result = tenantController.DeleteTenant(contentResult.Content.TenantId);
        }