コード例 #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
ファイル: AddProductTests.cs プロジェクト: kennyup/stacks
        public void ShouldBeSuccessful()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand("asdf"));

                stack.LastResult.ShouldBeSuccessful();
            }
        }
コード例 #5
0
        public void should_not_be_successful()
        {
            using (var stack = new TestStack(typeof(AddProduct)))
            {
                stack.Send(new AddProductCommand(null));

                stack.LastResult.ShouldNotBeSuccessful();
            }
        }
コード例 #6
0
        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);
            }
        }