public async Task ShouldNotReturnACustomer()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);

            // Act
            var result = await controller.GetCustomer("NONE");

            // Assert
            Assert.IsInstanceOfType(result, typeof (NotFoundResult));
        }
        public async Task ShouldReturnAListOfCustomers()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);

            // Act
            var customers = await controller.GetCustomers();

            // Assert
            Assert.AreEqual(2, customers.Count());
        }
        public async Task ShouldNotAllowUpdatingACustomerAsAnother()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);
            var customer = new Customer {CustomerID = "1"};

            // Act
            var result = await controller.PutCustomer("2", customer);

            // Assert
            Assert.IsInstanceOfType(result, typeof (BadRequestResult));
        }
        public async Task ShouldAllowUpdatingACustomer()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);
            var customer = new Customer {CustomerID = "1"};

            // Act
            var result = await controller.PutCustomer("1", customer) as StatusCodeResult;

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(HttpStatusCode.NoContent, result.StatusCode);
        }
        public async Task ShouldReturnACustomer()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);

            // Act
            var result = await controller.GetCustomer("1") as OkNegotiatedContentResult<Customer>;

            // Assert
            Assert.IsNotNull(result);
            var customer = result.Content;
            Assert.IsNotNull(customer);
            Assert.AreEqual("1", customer.CustomerID);
            Assert.AreEqual("Company 1", customer.CompanyName);
        }
        public async Task ShouldAcceptPostingANewCustomer()
        {
            // Arrange
            var repo = new DummyCustomerRepository();
            var controller = new TestableController(repo);
            var newCustomer = new Customer
            {
                CompanyName = "The new Company"
            };

            // Act  
            var result = await controller.PostCustomer(newCustomer) as CreatedAtRouteNegotiatedContentResult<Customer>;

            // Assert
            Assert.IsNotNull(result);
            var addedCustomer = result.Content;
            Assert.AreEqual("DefaultApi", result.RouteName);
            Assert.AreEqual(addedCustomer.CustomerID, result.RouteValues["Id"]);

            Assert.IsNotNull(addedCustomer.CustomerID);
            Assert.IsNotNull(addedCustomer.CompanyName);
            Assert.IsNull(addedCustomer.ContactName);
        }