public async Task CreateProduct_WhenValidValues_ShouldReturnGuidId()
        {
            // Arrange
            var request = new CreateProductCommand
            {
                Name  = _name,
                Price = _price,
            };
            var commandHandler = new CreateProductCommand.CreateProductCommandHandler(_productRepositoryMock.Object, _productBusinessMock.Object);

            // Act
            var guidId = await commandHandler.Handle(request, CancellationToken.None);

            // Assert
            Assert.NotEqual(default, guidId);
Exemple #2
0
        public async Task Handle_ShouldPersistProduct()
        {
            var command = new CreateProductCommand
            {
                Title = "Do yet another thing."
            };

            var handler = new CreateProductCommand.CreateProductCommandHandler(Context);

            var result = await handler.Handle(command, CancellationToken.None);

            var entity = Context.Products.Find(result);

            entity.ShouldNotBeNull();
            entity.Title.ShouldBe(command.Title);
        }
        public async Task Handle_ShouldPersistsProduct()
        {
            var command = new CreateProductCommand
            {
                Name        = "Test",
                Price       = 1,
                Category    = Category.Dairy,
                Description = "This is a test"
            };

            var result = await _handler.Handle(command, CancellationToken.None);

            var entity = await UnitOfWork.Products.GetByIdAsync(result);

            entity.ShouldNotBeNull();
            entity.Name.ShouldBe(command.Name);
            entity.Price.ShouldBe(command.Price);
            entity.Category.ShouldBe(command.Category);
            entity.Description.ShouldBe(command.Description);
        }