public async Task CreateRegionAnnualReportById_Invalid_NullExcept_Test() { // Arrange _regionAnnualReportService .Setup(x => x.CreateByNameAsync(It.IsAny <User>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <RegionAnnualReportQuestions>())) .Throws(new NullReferenceException()); // Act var expected = StatusCodes.Status404NotFound; var result = await _regionController.CreateRegionAnnualReportById(1, 2021, new RegionAnnualReportQuestions()); var actual = (result as StatusCodeResult).StatusCode; // Assert Assert.NotNull(result); Assert.AreEqual(expected, actual); }