public async Task GetTrucks() { // create model var model = new Model(); model.Description = Guid.NewGuid().ToString(); IActionResult actionResult = await _modelController.PostModel(model); var modelCreatedResult = actionResult as CreatedAtActionResult; Assert.IsNotNull(modelCreatedResult); Assert.AreEqual(201, modelCreatedResult.StatusCode); model.ModelId = Convert.ToInt32(modelCreatedResult.RouteValues["id"]); // create truck var truck = new Truck(); truck.Chassis = Guid.NewGuid().ToString(); truck.Year = Convert.ToInt16(new Random().Next(1900, 2019)); truck.Model = model; actionResult = await _truckController.PostTruck(truck); var createdResult = actionResult as CreatedAtActionResult; Assert.IsNotNull(createdResult); Assert.AreEqual(201, createdResult.StatusCode); // get all var models = _truckController.GetTrucks(); Assert.IsNotNull(models); Assert.IsTrue(models.Count() > 0); Assert.Pass(); }