Пример #1
0
        public async Task PostAsync_creates_new_diff()
        {
            // Arrange
            var inputRepository = new Mock <IInputRepository>();
            var diffRepository  = new Mock <IDiffRepository>();
            var eventBus        = new Mock <IRabbitMQEventBus>();

            var controller = new DiffController(
                _logger,
                diffRepository.Object,
                inputRepository.Object,
                _mapper,
                eventBus.Object);

            // Act
            var response = await controller.PostAsync();

            // Assert
            var createdResult = Assert.IsType <CreatedResult>(response);
            var result        = Assert.IsType <DiffViewModel>(createdResult.Value);

            Assert.NotNull(result);
            Assert.NotEqual(Guid.Empty, result.Id);

            diffRepository.Verify(dr =>
                                  dr.AddOneAsync(It.IsAny <Diff>()),
                                  Times.Once
                                  );
        }