Beispiel #1
0
        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());
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
 public void Post(MacGuffin macGuffin)
 {
     Console.WriteLine("This is a simulated API call to example.com");
 }
Beispiel #6
0
        public void Update(MacGuffin macGuffin)
        {
            _context.MacGuffin.Update(macGuffin);

            _context.SaveChanges();
        }
Beispiel #7
0
 public void AddNew(MacGuffin macGuffin)
 {
     _context.MacGuffin.Add(macGuffin);
     _context.SaveChanges();
 }