public void DealLocksController_GetLocks_Returns_OKResponseCode(int dealNumber, bool isLocked) { #region Arrange Mock <IEntityLockRepository> dealLockRepository = new Mock <IEntityLockRepository>(); SetupUserIdentity(); SetupDealLockRepository(dealLockRepository, dealNumber, userIdentity.UserId, isLocked); string url = $"{AppSettings.BASEURL}{ RouteHelper.DealsRoutePrefix }/{dealNumber}/locks"; //string url = $"{AppSettings.BASEURL}{RouteHelper.DealsRoutePrefix}{RouteHelper.DealLocksPrefix}"; var httpRequest = new HttpRequestMessage(new HttpMethod(AppSettings.HTTPGET), url); DealLocksController dealLocksController = CreateDealLocksController(httpRequest, dealLockRepository.Object); #endregion #region Act var response = dealLocksController.GetLocks(dealNumber); var contentResult = response as NegotiatedContentResult <ResponseItem <EntityLock> >; #endregion #region Assert #region Expected Data var expectedDealLock = new EntityLock() { entityId = dealNumber, entityTypeName = EntityType.Deals.ToString(), lockedByDisplayName = "John Doe", lockedTimestamp = DateTime.MinValue }; string expectedURL = ($"/{ RouteHelper.DealsRoutePrefix }/{dealNumber }/locks"); var expectedMessages = new List <Message>(); Message expectedMessage = new Warning("entityID", $"{ expectedDealLock.lockedByDisplayName} has locked this deal for edit"); expectedMessages.Add(expectedMessage); IList <Link> links = null; ResponseItem <EntityLock> expectedContent = new ResponseItem <EntityLock>(expectedURL, expectedDealLock, links, expectedMessages); #endregion Assertions.AssertOkResponse(contentResult); var actualDealLock = contentResult.Content.data; if (isLocked) { Assertions.AreEqualByJson(expectedContent, contentResult.Content); } else { Assert.IsNull(actualDealLock); Assert.IsNull(contentResult.Content.messages); Assert.IsNull(links); } #endregion }