Пример #1
0
        public void Should_Get_Item()
        {
            // Arrange
            var LabelToGet = new Label()
            {
                Id     = 10,
                Color  = "#ffffff",
                Title  = "testItem",
                UserId = "testID"
            };

            var repository = new Mock <IRepository <Label> >();

            repository.Setup(u => u.GetItem(10)).Returns(LabelToGet);

            // Act
            var service = new LabelService(_mapper, repository.Object);
            var result  = service.GetById(10, "testID");

            // Assert
            Assert.NotNull(result);
            Assert.Equal(LabelToGet.Id, result.Id);
            Assert.Equal(LabelToGet.Color, result.Color);
            Assert.Equal(LabelToGet.Title, result.Title);
            Assert.Equal(LabelToGet.UserId, result.UserId);
        }
Пример #2
0
        public void Should_GenereateEcxeption_When_Get_Item()
        {
            // Arrange
            var repository = new Mock <IRepository <Label> >();

            repository.Setup(u => u.GetItem(10)).Returns((Label)null);

            // Act
            var service = new LabelService(_mapper, repository.Object);

            //Assert
            Assert.Throws <Exception>(() => service.GetById(10, "testID"));
            repository.Verify(m => m.GetItem(10));
            repository.VerifyNoOtherCalls();
        }
Пример #3
0
        public IActionResult Edit(int id)
        {
            var label = _labelService.GetById(id, _userId);

            return(View(label));
        }