Пример #1
0
        public async Task DeleteWatch_DeletesWatch()
        {
            // Arrange
            var mockWatchRepository = new Mock <IWatchRepository>();

            mockWatchRepository.Setup(svc => svc.DeleteWatchAsync(15)).ReturnsAsync(true);
            var mockApiConfiguration = new Mock <IApiConfiguration>();
            var controller           = new WatchController(mockWatchRepository.Object, mockApiConfiguration.Object);

            // Act
            var response = await controller.DeleteWatchAsync(15);

            // Assert
            Assert.IsType <NoContentResult>(response);
        }
Пример #2
0
        public async Task DeleteWatch_ReturnsNotFound_ForInvalidId()
        {
            // Arrange
            var mockWatchRepository = new Mock <IWatchRepository>();

            mockWatchRepository.Setup(svc => svc.DeleteWatchAsync(15)).ReturnsAsync(false).Verifiable();
            var mockApiConfiguration = new Mock <IApiConfiguration>();
            var controller           = new WatchController(mockWatchRepository.Object, mockApiConfiguration.Object);

            // Act
            var response = await controller.DeleteWatchAsync(15);

            // Assert
            mockWatchRepository.Verify();
            var notFoundObjectResult = Assert.IsType <NotFoundObjectResult>(response);

            Assert.Equal("Watch with id 15 cannot be found.", notFoundObjectResult.Value);
        }