public void GetCustomerAndOrders_ShouldReturnNotFoundForCustomerThatDoesNotExist()
        {
            // Arrange
            var dataSourceEntities = new UnitTestDataSourceEntities();

            dataSourceEntities.Customers.Add(new Customer {
                id = 1, FirstName = "Olav", LastName = "Hundson", Email = "*****@*****.**"
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 1, Price = 1, CreatedDate = Convert.ToDateTime("5/6/2016"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 2, Price = 2, CreatedDate = Convert.ToDateTime("5/7/2017"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 3, Price = 3, CreatedDate = Convert.ToDateTime("5/8/2018"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 4, Price = 4, CreatedDate = Convert.ToDateTime("5/9/2019"), CustomerId = 1
            });
            var controller = new CustomersController(dataSourceEntities);

            // Act
            var actionResult = controller.GetCustomerAndOrdersAsync(4).Result;

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult)); // Should return 'not found' for a customer that does not exist
        }
        public void GetCustomerAndOrders_ShouldReturnCustomerAndAllHisOrders()
        {
            // Arrange
            var dataSourceEntities = new UnitTestDataSourceEntities();

            dataSourceEntities.Customers.Add(new Customer {
                id = 1, FirstName = "Olav", LastName = "Hundson", Email = "*****@*****.**"
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 1, Price = 1, CreatedDate = Convert.ToDateTime("5/6/2016"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 2, Price = 2, CreatedDate = Convert.ToDateTime("5/7/2017"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 3, Price = 3, CreatedDate = Convert.ToDateTime("5/8/2018"), CustomerId = 1
            });
            dataSourceEntities.CustomerOrders.Add(new CustomerOrder {
                id = 4, Price = 4, CreatedDate = Convert.ToDateTime("5/9/2019"), CustomerId = 1
            });
            var controller = new CustomersController(dataSourceEntities);

            // Act
            var actionResult  = controller.GetCustomerAndOrdersAsync(1).Result;
            var contentResult = actionResult as OkNegotiatedContentResult <CustomerAndOrders>;
            var content       = contentResult.Content;

            // Assert
            Assert.IsNotNull(content);                           // Should not be null
            Assert.AreEqual(4, content.Orders.Count);            // Should return all the 4 orders that belong to a customer
            Assert.AreEqual("Olav", content.Customer.FirstName); // The customer's name should match the returned name
        }