Esempio n. 1
0
        public void TestCreateSameSerialNumberProductUnitAsync()
        {
            ContextSeeder.Seed();
            var braBo = new BrandBusinessObject();
            var bra   = new Brand("Barraca do Tejo");

            braBo.Create(bra);
            var catBo = new CategoryBusinessObject();
            var cat   = new Category("Non-Alcoholic Beverages");

            catBo.Create(cat);
            var pmbo    = new ProductModelBusinessObject();
            var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id);

            pmbo.Create(prodMod);
            var sbo = new ShoppingBasketBusinessObject();
            var sbk = sbo.ListNotDeleted().Result.First();

            var bo        = new ProductUnitBusinessObject();
            var item      = bo.ListAsync().Result.Result.FirstOrDefault();
            var ebo       = new EstablishmentBusinessObject();
            var est       = ebo.ListNotDeleted().Result.First();
            var prodUnit  = new ProductUnit(item.SerialNumber, false, prodMod.Id, est.Id, sbk.Id);
            var resCreate = bo.CreateAsync(prodUnit).Result;

            Assert.IsTrue(!resCreate.Result);
        }
Esempio n. 2
0
        public void TestListCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo      = new CategoryBusinessObject();
            var resList = bo.ListAsync().Result;

            Assert.IsTrue(resList.Success && resList.Result.Count == 1);
        }
Esempio n. 3
0
        public void TestDeleteCategorys()
        {
            ContextSeeder.Seed();
            var bo         = new CategoryBusinessObject();
            var resList    = bo.List();
            var resDelete  = bo.Delete(resList.Result.First().Id);
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted).ToList();

            Assert.IsTrue(resDelete.Success && resNotList.Count == 0);
        }
Esempio n. 4
0
        public void TestCreateAndReadCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CategoryBusinessObject();
            var reg       = new Category("Alcoholic Beverages");
            var resCreate = bo.CreateAsync(reg).Result;
            var resGet    = bo.ReadAsync(reg.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Esempio n. 5
0
        public void TestDeleteCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CategoryBusinessObject();
            var resList   = bo.ListAsync().Result;
            var resDelete = bo.DeleteAsync(resList.Result.First().Id).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resDelete.Success && resList.Success && resList.Result.Count == 0);
        }
Esempio n. 6
0
        public void TestCreateSameNameCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo        = new CategoryBusinessObject();
            var item      = bo.ListAsync().Result.Result.FirstOrDefault();
            var reg       = new Category(item.Name);
            var resCreate = bo.CreateAsync(reg).Result;

            Assert.IsTrue(!resCreate.Result);
        }
Esempio n. 7
0
        public void TestUpdateSameNameCategoryAsync()
        {
            ContextSeeder.Seed();
            var bo  = new CategoryBusinessObject();
            var cat = new Category("Alcoholic Beverages");

            bo.Create(cat);
            cat.Name = "Non-Alcoholic Beverages";
            var resUpdate = bo.UpdateAsync(cat).Result;

            Assert.IsTrue(!resUpdate.Result);
        }
Esempio n. 8
0
        public void TestUpdateCategorynAsync()
        {
            ContextSeeder.Seed();
            var bo      = new CategoryBusinessObject();
            var resList = bo.ListAsync().Result;
            var item    = resList.Result.FirstOrDefault();

            item.Name = "It's just wine";
            var resUpdate = bo.UpdateAsync(item).Result;

            resList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(resList.Success && resUpdate.Success && resList.Result.First().Name == "It's just wine");
        }
        public void TestUpdateSameBarCodeProductModelAsync()
        {
            ContextSeeder.Seed();
            var bo      = new ProductModelBusinessObject();
            var bra     = bo.ListNotDeletedAsync().Result.Result.First();
            var catBo   = new CategoryBusinessObject();
            var cat     = catBo.ListNotDeletedAsync().Result.Result.First();
            var prodMod = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id);

            prodMod.BarCode = "506-1237-424";
            var resUpdate = bo.UpdateAsync(prodMod).Result;

            Assert.IsTrue(!resUpdate.Result);
        }
        public void TestCreateAndReadProductModelAsync()
        {
            ContextSeeder.Seed();
            var braBo = new BrandBusinessObject();
            var bra   = braBo.ListNotDeletedAsync().Result.Result.First();
            var catBo = new CategoryBusinessObject();
            var cat   = catBo.ListNotDeletedAsync().Result.Result.First();

            var bo        = new ProductModelBusinessObject();
            var prodMod   = new ProductModel("Vinho Branco", "506-1237-422", "", 4.24, 0.80, Measure.L, bra.Id, cat.Id);
            var resCreate = bo.CreateAsync(prodMod).Result;

            var resGet = bo.ReadAsync(prodMod.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }