public void GetData_WhenCalledWithFoo_InvokeReportAbuseUsageAndReturnsHttpDenied() { // Arrange var controller = new DataPropertyController { DataService = dataService, ReportService = reportService }; var forbidden = new HttpStatusCodeResult(HttpStatusCode.Forbidden); // act ActionResult foo = controller.GetData(subject: "foo"); var fooHttpStatusCodeResult = foo as HttpStatusCodeResult; // Assert Assert.IsNotNull(fooHttpStatusCodeResult); Assert.AreEqual(fooHttpStatusCodeResult.StatusCode, forbidden.StatusCode); dataService .AssertWasNotCalled(s => s.GetData(Arg<string>.Is.Anything)); reportService .AssertWasCalled(s => s.ReportAbuseUsage(Arg<string>.Is.Anything)); }
public void GetData_WhenCalledWithAnythingButFoo_InvokeGetDataAndReturnsJsonResult() { // Arrange var controller = new DataPropertyController { DataService = dataService, ReportService = reportService }; // act ActionResult news = controller.GetData(subject: "news"); ActionResult fooish = controller.GetData(subject: "fooish"); // Assert Assert.IsNotNull(news as JsonResult); Assert.IsNotNull(fooish as JsonResult); dataService .AssertWasCalled(s => s.GetData(Arg<string>.Is.Anything)); reportService .AssertWasNotCalled(s => s.ReportAbuseUsage(Arg<string>.Is.Anything)); }