Пример #1
0
        public void a_validation_error_should_be_returned()
        {
            using (var context = new TestStack(typeof(AddProduct)))
            {
                context.Send(new StockProductCommand("asdf", -1));

                context.LastResult.ShouldContainMessage("The product quantity must be greater than 0.");
            }
        }
Пример #2
0
        public void a_validation_error_should_be_returned()
        {
            using (var context = new TestStack(typeof(AddProduct)))
            {
                context.Send(new AddProductCommand("abcde", ""));

                context.LastResult.ShouldContainMessage("A product name must be unique.");
            }
        }
Пример #3
0
        public void a_product_with_the_name_and_description_are_added()
        {
            using (var context = new TestStack(typeof(AddProduct)))
            {
                context.Send(new AddProductCommand("abcde", ""));

                context.Domain.Find <Product>().Result.Count().Should().Be(1);
            }
        }
Пример #4
0
        public void ShouldBeSuccessful()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand("asdf"));

                stack.LastResult.ShouldBeSuccessful();
            }
        }
        public void should_not_be_successful()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand(null));

                stack.LastResult.ShouldNotBeSuccessful();
            }
        }
        public void should_have_the_correct_message()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand(null));

                stack.LastResult.ShouldContainMessage("Name cannot be null.");
            }
        }
Пример #7
0
        public void should_add_a_product()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand("name"));

                stack.Domain.Find <Product>(e => e.Name == "name").Result.Count().Should().Be(1);
            }
        }
Пример #8
0
        public void should_add_an_item_if_not_exists()
        {
            using (var context = new TestStack(typeof(AddProduct)))
            {
                context.Send(new StockProductCommand("asdf", 10));

                var target = context.Domain.Find <StockItem>(e => e.ProductId == "asdf").Result.FirstOrDefault();

                target.Should().NotBeNull();
            }
        }
Пример #9
0
        public void should_increment_the_quantity_of_existing_item()
        {
            using (var context = new TestStack(typeof(AddProduct)))
            {
                context.Send(new StockProductCommand(StockOne.ProductId, 10));

                var target = context.Domain.Find <StockItem>(e => e.ProductId == StockOne.ProductId).Result.FirstOrDefault();

                target.Quantity.Should().Be(15);
            }
        }