示例#1
0
        public void UT_Admin_categories()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCategoriesV1(repo);

            var resp = service.Exec(null, new AuthenticatedUser(), 0, 10);

            if (resp.list.Count != 1)
            {
                Assert.Fail("categories // fail 1");
            }

            if (resp.total != 1)
            {
                Assert.Fail("categories // fail 2");
            }

            if (resp.list[0].Id != 1)
            {
                Assert.Fail("categories // fail 3.1");
            }

            if (resp.list[0].Name != "teste")
            {
                Assert.Fail("categories // fail 3.2");
            }
        }
示例#2
0
        public void UT_Admin_CreateAccount_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateAccountV1(repo);

            if (service.Exec(null, new NewUserData {
                Name = ""
            }))
            {
                Assert.Fail("CreateAccount // Name empty accepted");
            }
        }
示例#3
0
        public void UT_Admin_CreateCategory_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateCategoryV1(repo);

            if (!service.Exec(null, new NewCategoryData {
                Name = "pass"
            }))
            {
                Assert.Fail("CreateCategory // Not existing user should create account");
            }
        }
示例#4
0
        public void UT_Admin_CreateCategory_CategoryExist()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateCategoryV1(repo);

            if (service.Exec(null, new NewCategoryData {
                Name = "xxx"
            }))
            {
                Assert.Fail("CreateCategory // Existing user cannot create same account");
            }
        }
示例#5
0
        public void UT_Admin_EditProduct_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminEditProductV1(repo);

            if (!service.Exec(null, new AuthenticatedUser(), new NewProductData {
                Name = "test", Id = 1
            }))
            {
                Assert.Fail("EditProduct // Data ok should edit");
            }
        }
示例#6
0
        public void UT_Admin_EditCategory_IdInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminEditCategoryV1(repo);

            if (service.Exec(null, new NewCategoryData {
                Name = "xxxx", Id = 9999999
            }))
            {
                Assert.Fail("EditCategory // Id invalid");
            }
        }
示例#7
0
        public void UT_Admin_CreateAccount_UserExist()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateAccountV1(repo);

            if (service.Exec(null, new NewUserData {
                Name = "xxx", Email = "*****@*****.**", Password = "******"
            }))
            {
                Assert.Fail("CreateAccount // Existing user cannot create same account");
            }
        }
示例#8
0
        public void UT_Admin_EditProduct_IdInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminEditProductV1(repo);

            if (service.Exec(null, new AuthenticatedUser(), new NewProductData {
                Name = "test", Id = 0
            }))
            {
                Assert.Fail("EditProduct // Name empty accepted");
            }
        }
示例#9
0
        public void UT_Admin_CreateAccount_PasswordInvalid_2()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateAccountV1(repo);

            if (service.Exec(null, new NewUserData {
                Name = "xxx", Email = "*****@*****.**", Password = "******"
            }))
            {
                Assert.Fail("CreateAccount // cannot be empty");
            }
        }
示例#10
0
        public void UT_Admin_CreateAccount_EmailInvalid_3()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateAccountV1(repo);

            if (service.Exec(null, new NewUserData {
                Name = "xxx", Email = "fddd@fdsd"
            }))
            {
                Assert.Fail("CreateAccount // Email invalid 3 accepted");
            }
        }
示例#11
0
        public void UT_Admin_CreateAccount_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateAccountV1(repo);

            if (!service.Exec(null, new NewUserData {
                Name = "xxx", Email = "*****@*****.**", Password = "******"
            }))
            {
                Assert.Fail("CreateAccount // Not existing user should create account");
            }
        }
示例#12
0
        public void UT_Admin_EditSubCategory_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminEditSubCategoryV1(repo);

            if (service.Exec(null, new NewSubCategoryData {
                Name = "", Id = 1
            }))
            {
                Assert.Fail("EditSubCategory // Name empty accepted");
            }
        }
示例#13
0
        public void UT_Admin_EditSubCategory_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminEditSubCategoryV1(repo);

            if (!service.Exec(null, new NewSubCategoryData {
                Name = "xxx", Id = 1
            }))
            {
                Assert.Fail("EditSubCategory // Not existing user should create account");
            }
        }
示例#14
0
        public void UT_Admin_CreateProduct_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateProductV1(repo);

            if (service.Exec(null, new AuthenticatedUser(), new NewProductData {
                Name = ""
            }))
            {
                Assert.Fail("CreateProduct // Name empty accepted");
            }
        }
示例#15
0
        public void UT_Admin_products()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminProductsV1(repo);

            var resp = service.Exec(null, 1, 1, 0, 10);

            if (resp.list.Count != 1)
            {
                Assert.Fail("products // fail 1");
            }
        }
示例#16
0
        public void UT_Admin_CreateProduct_SubCategID_Invalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateProductV1(repo);

            if (service.Exec(null, new AuthenticatedUser(), new NewProductData {
                Name = "test", ProductCategoryID = 1, ProductSubCategoryID = 0
            }))
            {
                Assert.Fail("CreateProduct // Subcategory invalid accepted");
            }
        }
示例#17
0
        public void UT_Admin_CreateProduct_Product_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateProductV1(repo);

            if (!service.Exec(null, new AuthenticatedUser(), new NewProductData {
                Name = "test", ProductCategoryID = 1, ProductSubCategoryID = 2
            }))
            {
                Assert.Fail("CreateProduct // OKk and was not created");
            }
        }
示例#18
0
        public void UT_Admin_CreateCategory_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateSubCategoryV1(repo);

            if (!service.Exec(null, new NewSubCategoryData {
                ProductCategoryID = 1, Name = "xxx"
            }))
            {
                Assert.Fail("CreateSubCategory // ok not passed");
            }
        }
示例#19
0
        public void UT_Admin_CreateSubCategory_NameInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCreateSubCategoryV1(repo);

            if (service.Exec(null, new NewSubCategoryData {
                ProductCategoryID = 1, Name = ""
            }))
            {
                Assert.Fail("CreateSubCategory // Name empty accepted");
            }
        }
示例#20
0
        public void UT_Admin_Authenticate_OK()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (!service.Exec(null, new LoginInformation {
                Login = "******", Passwd = "123456"
            }, ref ua))
            {
                Assert.Fail("Authenticate // Failed!");
            }
        }
示例#21
0
        public void UT_Admin_Authenticate_PasswordInvalid_2()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (service.Exec(null, new LoginInformation {
                Login = "******", Passwd = "123"
            }, ref ua))
            {
                Assert.Fail("Authenticate // Password invalid passed");
            }
        }
示例#22
0
        public void UT_Admin_Authenticate_LoginInvalid()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminAuthenticateV1(repo);
            var ua      = new AuthenticatedUser();

            if (service.Exec(null, new LoginInformation {
                Login = ""
            }, ref ua))
            {
                Assert.Fail("Authenticate // Login empty accepted");
            }
        }
示例#23
0
        public void UT_Admin_category()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminCategoryV1(repo);

            var resp = service.Exec(null, new AuthenticatedUser(), 1);

            if (resp.Id != 1)
            {
                Assert.Fail("category // fail 1");
            }

            if (resp.Name != "test")
            {
                Assert.Fail("category // fail 2");
            }
        }
示例#24
0
        public void UT_Admin_product()
        {
            var repo    = new mockAdminRepository();
            var service = new AdminProductV1(repo);

            var resp = service.Exec(null, 1);

            if (resp.Id != 1)
            {
                Assert.Fail("product // fail 1");
            }

            if (resp.Name != "test")
            {
                Assert.Fail("product // fail 2");
            }
        }