public void CreateClientAsync_IdentityAdminThrows_ReturnsErrors() { ClientServiceImpl.SetupCreateClientAsync(new Exception("Boom")); var propertyValuesNoName = new List <PropertyValue> { new PropertyValue { Type = "ClientName", Value = "testName" }, new PropertyValue { Type = "ClientId", Value = "testId" } }; var response = Post("api/Clients", propertyValuesNoName); Assert.AreEqual(HttpStatusCode.InternalServerError, response.StatusCode); }
public void CreateClientAsync_ValidModel_CallsIdentityAdmin() { ClientServiceImpl.SetupCreateClientAsync(new CreateResult { Subject = "123" }); var propertyValues = new List <PropertyValue> { new PropertyValue { Type = "ClientName", Value = "testName" }, new PropertyValue { Type = "ClientId", Value = "testId" } }; Post("api/Clients", propertyValues); ClientServiceImpl.VerifyCreateClientAsync(); }
public void CreateClientAsync_IdentityAdminReturnsSuccess_CorrectResults() { ClientServiceImpl.SetupCreateClientAsync(new CreateResult { Subject = "123" }); var propertyValues = new List <PropertyValue> { new PropertyValue { Type = "ClientName", Value = "testName" }, new PropertyValue { Type = "ClientId", Value = "testId" } }; var response = Post("api/Clients", propertyValues); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.AreEqual("/api/clients/123", response.Headers.Location.ToString()); }
public void CreateClientAsync_IdentityAdminReturnsErrors_ReturnsErrors() { ClientServiceImpl.SetupCreateClientAsync("foo", "bar"); var propertyValuesNoName = new List <PropertyValue> { new PropertyValue { Type = "ClientName", Value = "testName" }, new PropertyValue { Type = "ClientId", Value = "testId" } }; var response = Post("api/Clients", propertyValuesNoName); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); var error = response.Content.ReadAsAsync <ErrorModel>().Result; Assert.AreEqual(2, error.Errors.Length); CollectionAssert.Contains(error.Errors, "foo"); CollectionAssert.Contains(error.Errors, "bar"); }