示例#1
0
        public async Task Should_Create_A_Estoque()
        {
            // Arrange
            var fabricanteOut = await _fabricanteAppService.CreateFabricante(
                new CreateFabricanteInput
            {
                Name        = "Fabricante_test",
                Description = "Description_test"
            });

            fabricanteOut.Id.ShouldBe(1);

            var fabricante = await _fabricanteAppService.GetById(1);

            var produtoOut = _produtoAppService.CreateProduto(
                new CreateProdutoInput
            {
                Name                    = "Produto_test",
                Description             = "Description_test",
                AssignedManufacturer_Id = fabricanteOut.Id,
                AssignedManufacturer    = new Entities.Fabricante
                {
                    Id          = fabricante.Id,
                    Name        = fabricante.Name,
                    Description = fabricante.Description
                },
                Consumable = true
            });

            var produto = await _produtoAppService.GetById(1);

            // Act
            var estoqueOut = _estoqueAppService.CreateEstoque(
                new CreateEstoqueInput
            {
                Stock = 5,
                Price = 4.9f,
                AssignedProduct_Id = produtoOut.Id,
                AssignedProduct    = new Entities.Produto
                {
                    Id                      = produtoOut.Id,
                    Name                    = produto.Name,
                    Description             = produto.Description,
                    AssignedManufacturer_Id = produto.AssignedManufacturer_Id,
                    AssignedManufacturer    = produto.AssignedManufacturer,
                    Consumable              = produto.Consumable
                }
            });

            // Assert
            UsingDbContext(context =>
            {
                var estoque_teste = context.Estoque.FirstOrDefault();
                estoque_teste.ShouldNotBeNull();
            });
        }
        public async Task Should_Create_A_Produto()
        {
            // Arrange
            var fabricanteOut = await _fabricanteAppService.CreateFabricante(
                new CreateFabricanteInput
            {
                Name        = "Fabricante_test",
                Description = "Description_test"
            });

            fabricanteOut.Id.ShouldBe(1);

            var fabricante = await _fabricanteAppService.GetById(1);

            // Act
            var produtoOut = _produtoAppService.CreateProduto(
                new CreateProdutoInput
            {
                Name                    = "Produto_test",
                Description             = "Description_test",
                AssignedManufacturer_Id = fabricanteOut.Id,
                AssignedManufacturer    = new Entities.Fabricante
                {
                    Id          = fabricante.Id,
                    Name        = fabricante.Name,
                    Description = fabricante.Description
                },
                Consumable = true
            });

            // Assert
            UsingDbContext(context =>
            {
                var produto_teste = context.Produtos.FirstOrDefault();
                produto_teste.ShouldNotBeNull();
            });
        }
        public async Task Should_Get_A_FabricanteById()
        {
            // Arrange
            var fabricanteId = await _fabricanteAppService.CreateFabricante(
                new CreateFabricanteInput
            {
                Name        = "Fabricante_test",
                Description = "Description_test"
            });

            UsingDbContext(context =>
            {
                var fabricante_teste = context.Fabricantes.FirstOrDefault();
                fabricante_teste.ShouldNotBeNull();
            });

            // Act
            var fabricante = await _fabricanteAppService.GetById(1);

            // Assert
            fabricante.Name.ShouldBe("Fabricante_test");
            fabricante.Id.ShouldBe(1);
        }