public async Task UpdatesExistingResponse() { _config.Setup(_ => _.GetSection(It.Is <string>(s => s == FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId.ToString()))).Returns(_configSection.Object); _configSection.Setup(a => a.Value).Returns("10"); var latestResponse = new Response { ResponseId = 15, ResponseDateUtc = new DateTime(2020, 3, 18, 1, 0, 1), Responder = "old user", Answer = false, QuestionId = 10, Attributes = new Dictionary <string, string> { { "LoadshopLoadId", VALID_LOAD_ID.ToString() } } }; _feedbackClient.Setup(_ => _.SearchResponsesAsync(It.IsAny <ResponseSearchCriteria>())).ReturnsAsync( new List <Response> { new Response() { ResponseId = 1, ResponseDateUtc = new DateTime(2020, 3, 18, 1, 0, 0) }, latestResponse, new Response() { ResponseId = 2, ResponseDateUtc = new DateTime(2020, 3, 18, 1, 0, 0) } }); _feedbackClient.Setup(_ => _.SaveResponseAsync(It.IsAny <Response>())).ReturnsAsync(new Response() { ResponseId = 15 }); var data = new QuestionResponseData { FeedbackQuestionCode = FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId, Answer = true, LoadId = VALID_LOAD_ID }; await _svc.SaveResponseAsync(data); _feedbackClient.Verify(_ => _.SaveResponseAsync(It.Is <Response>(x => x.QuestionId == 10 && x.Attributes["LoadshopLoadId"] == VALID_LOAD_ID.ToString() && x.Answer == true && x.ResponseDateUtc != new DateTime(2020, 3, 18, 1, 0, 1) &&//date should be updated x.Responder == VALID_USER_NAME ))); }
public async Task CreatesNewResponse(bool answer) { _config.Setup(_ => _.GetSection(It.Is <string>(s => s == FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId.ToString()))).Returns(_configSection.Object); _configSection.Setup(a => a.Value).Returns("10"); _feedbackClient.Setup(_ => _.SaveResponseAsync(It.IsAny <Response>())).ReturnsAsync(new Response() { ResponseId = 15 }); var data = new QuestionResponseData { FeedbackQuestionCode = FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId, Answer = answer, LoadId = VALID_LOAD_ID }; await _svc.SaveResponseAsync(data); _feedbackClient.Verify(_ => _.SaveResponseAsync(It.Is <Response>(x => x.QuestionId == 10 && x.Attributes["LoadshopLoadId"] == VALID_LOAD_ID.ToString() && x.Answer == answer ))); }
public async Task CallsSearchResponsesWithExpectedValues() { _config.Setup(_ => _.GetSection(It.Is <string>(s => s == FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId.ToString()))).Returns(_configSection.Object); _configSection.Setup(a => a.Value).Returns("10"); var data = new QuestionResponseData { FeedbackQuestionCode = FeedbackQuestionCodeEnum.LB_ShipperReuseCarrierQuestionId, Answer = true, LoadId = VALID_LOAD_ID }; await _svc.SaveResponseAsync(data); _feedbackClient.Verify(_ => _.SearchResponsesAsync(It.Is <ResponseSearchCriteria>(x => x.QuestionId == 10 && x.Attributes["LoadshopLoadId"] == VALID_LOAD_ID.ToString() ))); }