public void CallBack_FromThirdParty_StartedCallBack_ExpectedUpdatedRecord() { //Arrange MacGuffin mcGuffin = new MacGuffin("test"); _mockMacGuffinRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(mcGuffin); var controller = CreateNewController(); //Act var result = controller.StartedCallBack(1); //Assert var apiResult = Assert.IsType <NoContentResult>(result); _mockMacGuffinRepository.Verify(x => x.Update(mcGuffin), Times.AtLeastOnce()); }
public void Check_getter() { //Arrange MacGuffin mcGuffin = new MacGuffin("test"); _mockMacGuffinRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(mcGuffin); var controller = CreateNewController(); //Act var result = controller.GetMacGuffin(1); //Assert var apiResult = Assert.IsType <OkObjectResult>(result); apiResult.Value.Should().Be(mcGuffin); }
public void CallBack_FromThirdParty_AddStatus_ExpectedUpdatedRecord() { //Arrange MacGuffin mcGuffin = new MacGuffin("test"); _mockMacGuffinRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(mcGuffin); var controller = CreateNewController(); //Act StatusDto status = new StatusDto { Status = "complete", Detail = "just finished" }; var result = controller.AddStatus(1, status); //Assert var apiResult = Assert.IsType <NoContentResult>(result); _mockMacGuffinRepository.Verify(x => x.Update(mcGuffin), Times.AtLeastOnce()); }
public ActionResult NewRequest(MacGuffinDto incomingDto) { var macGuffin = new MacGuffin(incomingDto.Body); _thirdPartyService.Post(macGuffin); _macGuffinRepository.AddNew(macGuffin); var statusURi = new UriBuilder { Path = $"callback/{macGuffin.Id}", Host = _httpContextAccessor.HttpContext.Request.Host.Host }; if (_httpContextAccessor.HttpContext.Request.Host.Port.HasValue) { statusURi.Port = (int)_httpContextAccessor.HttpContext.Request.Host.Port; } var userCallBack = statusURi.Uri; return(Created(userCallBack, macGuffin)); }
public void Post(MacGuffin macGuffin) { Console.WriteLine("This is a simulated API call to example.com"); }
public void Update(MacGuffin macGuffin) { _context.MacGuffin.Update(macGuffin); _context.SaveChanges(); }
public void AddNew(MacGuffin macGuffin) { _context.MacGuffin.Add(macGuffin); _context.SaveChanges(); }