private async Task <IActionResult> PostLeft() { var controller = new DiffController(_mediator.Object); var result = await controller.PostLeft(_id, _json); _mediator.Verify(_mediatorSendRequest, Times.Once); return(result); }
public void ShouldNotSaveLeft() { var e = new Entity() { Id = 700 }; var ctrl = new DiffController(); var res = ctrl.PostLeft(e.Id, e) as BadRequestObjectResult; Assert.AreEqual(400, res.StatusCode); }
public async Task PostLeftReturnsBadRequestResultWhenModelIsInvalid() { var service = Substitute.For <IDifferenceService>(); var controller = new DiffController(service); controller.ModelState.AddModelError("error", "some error"); var result = await controller.PostLeft(10, new SourceContentRequest()); result.Should().BeOfType <BadRequestResult>(); }
public async Task PostLeftReturnsBadRequestResultWhenModelDataIsNotBase64() { var service = Substitute.For <IDifferenceService>(); var request = new SourceContentRequest { Data = "__." }; var controller = new DiffController(service); var result = await controller.PostLeft(10, request); result.Should().BeOfType <BadRequestResult>(); }
public void ShouldGetEntityLeft() { var e = new Entity() { Id = 800, Left = left }; var controller = new DiffController(); controller.PostLeft(e.Id, e); var res = controller.GetLeft(e.Id).Value; Assert.AreEqual(e.Left, res); }
public void ShouldSaveLeft() { var e = new Entity() { Id = 500, Left = left }; e.Id = new Random().Next(20, 30); var ctrl = new DiffController(); var res = ctrl.PostLeft(e.Id, e) as OkObjectResult; Assert.AreEqual(200, res.StatusCode); }
public async Task PostLeftAddsSourceForGivenDiff(int diffId) { var data = new byte[] { 1, 2, 3 }; var service = Substitute.For <IDifferenceService>(); var request = new SourceContentRequest { Data = Convert.ToBase64String(data) }; var controller = new DiffController(service); var result = await controller.PostLeft(diffId, request); result.Should().BeOfType <OkResult>(); await service.Received().AddSourceAsync(diffId, Arg.Is <SourceContent>( c => c.SourceSide == SourceSide.Left && c.Data.SequenceEqual(data))); }
public void PostCorrectDataTest() { //Arrange string id = "1"; _dataManagerMock.Setup(mock => mock.Add(id + "-left", _img1)); //Act var response = _sut.PostLeft(id, new DiffRequest() { Data = _img1 }); //Assert Assert.IsInstanceOfType(response, typeof(CreatedNegotiatedContentResult <string>)); }