public void PostingABodyReturnsAValidAbsoluteURL() { //Arrange var key = "abcdef1234"; var testData = "Test data"; var serviceName = "service name"; var mockService = new MockService(key, serviceName, testData); var responseRepository = new Mock <IMockServiceStore>(); var controller = new DummyController(responseRepository.Object) { Request = request }; responseRepository.Setup(x => x.CreateAsync(mockService)); dynamic service = new object(); service.name = "Unit test name"; //Act var returnedString = controller.Post(service); //Assert var url = new Uri(returnedString.ToString()); Assert.IsTrue(url.IsAbsoluteUri); }
public async Task PostReturnsUrlContainingResponseKey() { //Arrange var key = "abcdef1234"; var testData = "Test data"; var mockResponseRepository = new Mock <IMockServiceStore>(); var mockService = new MockService("key", "name", "body"); var controller = new DummyController(mockResponseRepository.Object) { Request = request }; mockResponseRepository.Setup(r => r.CreateAsync(mockService)); //Act var returnedString = await controller.Post(mockService); //Assert StringAssert.Contains(key, returnedString.ToString()); }