public void AddLabel_InValidData() { _labelService.Setup(p => p.AddLabel(null)).Returns(new LabelDTO()); var returnObj = labelController.AddLabel(null); var okResult = returnObj.Result as ObjectResult; var valueResult = okResult.Value as LabelDTO; Assert.IsTrue(valueResult == null); }
public void Post_NotExistingNamePassed_AddsItem() { // Act _ = controller.AddLabel( new Label() { name = "AddLabelTest", type = "test_type", userid = "0" } ).Result; // Assert var result = controller.GetLabels().Result; var items = Assert.IsType <List <Label> >(result.Value); Assert.Equal(3, items.Count); }
public void AddLabelTest() { var mediator = new Mock <IMediator>(); AddLabelCommand command = new AddLabelCommand { Label = new Label() { Name = "Label2" } }; mediator.Setup(e => e.Send(command, new System.Threading.CancellationToken())).Returns(Task.FromResult(1)); LabelController controller = new LabelController(mediator.Object); var result = controller.AddLabel(command); var response = result.Result as OkObjectResult; Assert.AreEqual(1, (int)response.Value); }