public void Get_WhenCalled_ReturnsAllItems() { // Act var result = controller.GetLabels().Result; // Assert var items = Assert.IsType <List <Label> >(result.Value); Assert.Equal(2, items.Count); }
public async void Return_Label_LabelAliasDtos() { //Arrange var service = CreateServiceWithLabels(); var controller = new LabelController(service); //Act var result = await controller.GetLabels(); //Assert var firstValue = result.First(); Assert.NotEmpty(result); Assert.True(firstValue.LabelValues.Count() == 2); }
public async void Return_Label_LanguageLabelDtos() { //Arrange var service = CreateServiceWithLabels(); var controller = new LabelController(service); //Act var result = await controller.GetLabels("da-DK"); //Assert var firstValue = result.First(); Assert.NotEmpty(result); Assert.Equal("Label Number: 0", firstValue.Alias); Assert.Equal("Værdi for 0 på dansk", firstValue.Value); }
public void GetLabel_ValidData() { List <LabelDTO> labelList = new List <LabelDTO>(); labelList.Add(new LabelDTO { Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }); labelList.Add(new LabelDTO { Id = 12, Description = "Label_12", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now }); _labelService.Setup(p => p.GetLabels()).Returns(labelList); var returnObj = labelController.GetLabels(); var okResult = returnObj as ObjectResult; var valueResult = okResult.Value as List <LabelDTO>; Assert.IsTrue(valueResult.Count == 2); }
public void GetLabelsTest() { var mediator = new Mock <IMediator>(); EmptyQuery <List <Domain.Models.Label> > command = new EmptyQuery <List <Domain.Models.Label> >(); List <Label> labels = new List <Label> { new Label() { Id = 1, Name = "Label1" } }; mediator.Setup(e => e.Send(command, new System.Threading.CancellationToken())).Returns(Task.FromResult(labels)); LabelController controller = new LabelController(mediator.Object); var result = controller.GetLabels(command); var response = result.Result as OkObjectResult; Assert.AreEqual(labels.Count, ((List <Label>)response.Value).Count); }