public async Task GetCustomer_Returns_Customer_If_Found() { // arrange var scope = new DefaultScope(); var expectedId = 12L; var getCustomerResponse = new GetCustomerResponse { Id = expectedId, SourceId = 123, IndustryCodes = new List <String> { "123123" }, Name = "good enough" }; scope.SetupUrlHelper(expectedId); scope.GetCustomerMock.Setup(x => x.GetAsync(expectedId)).ReturnsAsync( getCustomerResponse); // act var result = await scope.InstanceUnderTest.GetAsync(expectedId); // assert Assert.AreEqual(getCustomerResponse.Name, result.Value.Name); Assert.AreEqual(getCustomerResponse.SourceId, result.Value.SourceId); Assert.AreEqual(getCustomerResponse.IndustryCodes.First(), result.Value.IndustryCodes.First()); }
public async Task UpdateCustomer_Returns_Location_If_Successful() { // arrange var scope = new DefaultScope(); var expectedId = 12L; var saveCustomerRequest = new SaveCustomerRequest() { Name = "good enough" }; var saveCustomerResponse = new SaveCustomerResponse { Id = expectedId }; scope.UpdateCustomerMock.Setup(x => x.UpdateAsync(expectedId, saveCustomerRequest)).ReturnsAsync(saveCustomerResponse); scope.SetupUrlHelper(expectedId); // act var result = await scope.InstanceUnderTest.PutAsync(expectedId, saveCustomerRequest); // assert Assert.IsTrue(result.Value.Links.First().Href.EndsWith(expectedId.ToString())); Assert.AreEqual("self", result.Value.Links.First().Rel); Assert.AreEqual("GET", result.Value.Links.First().Method); }
public async Task GetCustomer_Returns_Location_If_Found() { // arrange var scope = new DefaultScope(); var expectedId = 12L; var getCustomerResponse = new GetCustomerResponse { Id = expectedId, Name = "good enough" }; scope.SetupUrlHelper(expectedId); scope.GetCustomerMock.Setup(x => x.GetAsync(expectedId)).ReturnsAsync( getCustomerResponse); // act var result = await scope.InstanceUnderTest.GetAsync(expectedId); // assert Assert.IsTrue(result.Value.Links.First().Href.EndsWith(expectedId.ToString())); Assert.AreEqual("self", result.Value.Links.First().Rel); Assert.AreEqual("GET", result.Value.Links.First().Method); }