Exemplo n.º 1
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            CategoryBuilder.BuildCategory(modelBuilder);
            OrderBuilder.BuildOrder(modelBuilder);
            OrderLineBuilder.BuildOrderLine(modelBuilder);
            CartBuilder.BuildCart(modelBuilder);
            ProductBuilder.BuildProduct(modelBuilder);
            UserProfileBuilder.BuildUserProfile(modelBuilder);
            CartLineBuilder.BuildCartLine(modelBuilder);

            base.OnModelCreating(modelBuilder);
        }
Exemplo n.º 2
0
            public void OrderLineBuilder_Should_Build_OrderLine_If_The_String_Passed_Is_In_The_Correct_Form()
            {
                //ARRANGE
                const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
                const string nums  = "0123456789";

                var numofnamelength   = rnd.Next(20);
                var numofpieceslength = rnd.Next(1, 3);

                OrderLineBuilder orderLineBuilder = new OrderLineBuilder();

                var name       = new string(Enumerable.Repeat(chars, numofnamelength).Select(s => s[rnd.Next(s.Length)]).ToArray());
                var quantity   = new string(Enumerable.Repeat(nums, numofpieceslength).Select(s => s[rnd.Next(s.Length)]).ToArray());
                var teststring = $"{name}:{quantity}";

                //ACT
                var result = orderLineBuilder.BuildOrderLine(teststring);

                //ASSERT
                Assert.AreEqual("All good.", result.Message);
                Assert.AreEqual(true, result.Success);
                Assert.AreEqual(name, result.Entity.ProductName);
                Assert.AreEqual(Int32.Parse(quantity), result.Entity.Quantity);
            }