Ejemplo n.º 1
0
        public void GetById_CallRepositoryGetById()
        {
            string guid = "00000000-0000-0000-0000-000000000001";

            MockRepository.Setup(a => a.GetById(Guid.Parse(guid)));

            var service = new Service.TodoService(MockRepository.Object);

            service.GetByID(Guid.Parse(guid));

            MockRepository.Verify(a => a.GetById(Guid.Parse(guid)), Times.Once);
        }
Ejemplo n.º 2
0
        public void GivenExistingId_GetById_ReturnsCorrectTodo()
        {
            string guid = "00000000-0000-0000-0000-000000000001";
            var    todo = new TodoModel
            {
                Id          = Guid.Parse(guid),
                Title       = "Test",
                Description = "Test Description",
                Status      = TodoStatus.InProgress,
                CreatedOn   = new DateTime(2020, 10, 11, 12, 13, 14),
                DueDate     = new DateTime(2021, 1, 24, 1, 22, 33)
            };

            MockRepository.Setup(a => a.GetById(todo.Id)).Returns(todo);
            var sercice = new Service.TodoService(MockRepository.Object);

            var servicedTodo = sercice.GetByID(Guid.Parse(guid));

            Assert.Equal(servicedTodo, todo);
        }