예제 #1
0
        public void GetProduct_ShouldReturnProductWithSameID()
        {
            var context = new TestStoreAppContext();

            context.Company.Add(GetDemoProduct());

            var controller = new CompaniesController(context);
            var result     = controller.GetProduct("Mahmoud") as OkNegotiatedContentResult <Company>;

            Assert.IsNotNull(result);
            Assert.AreEqual("Mahmoud", result.Content.Cemail);
        }
예제 #2
0
        public void DeleteProduct_ShouldReturnOK()
        {
            var context = new TestStoreAppContext();
            var item    = GetDemoProduct();

            context.Company.Add(item);

            var controller = new CompaniesController(context);
            var result     = controller.DeleteProduct("Mahmoud") as OkNegotiatedContentResult <Company>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Cemail, result.Content.Cemail);
        }
예제 #3
0
        public void GetProducts_ShouldReturnAllProducts()
        {
            var context = new TestStoreAppContext();
            List <UserInterests> usersInterests = new List <UserInterests>();

            usersInterests.Add(new UserInterests {
                Interest = "c++"
            });

            context.Users.Add(new Users()
            {
                Uemail        = "Mahmoud",
                FirstName     = "Mahmoud",
                LastName      = "Yaseen",
                Password      = "******",
                Age           = 20,
                Gender        = "male",
                Type          = "Admin",
                UserInterests = usersInterests
            });
            context.Users.Add(new Users()
            {
                Uemail        = "Mahmoud",
                FirstName     = "Mahmoud",
                LastName      = "Yaseen",
                Password      = "******",
                Age           = 20,
                Gender        = "male",
                Type          = "Admin",
                UserInterests = usersInterests
            });
            context.Users.Add(new Users()
            {
                Uemail        = "Mahmoud",
                FirstName     = "Mahmoud",
                LastName      = "Yaseen",
                Password      = "******",
                Age           = 20,
                Gender        = "male",
                Type          = "Admin",
                UserInterests = usersInterests
            });

            var controller = new UsersController(context);
            var result     = controller.GetProducts() as TestUserDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }
예제 #4
0
        public void GetProducts_ShouldReturnAllProducts()
        {
            var context = new TestStoreAppContext();
            List <CompanyInterests> companyInterests = new List <CompanyInterests>();

            companyInterests.Add(new CompanyInterests {
                Interest = "c++"
            });

            context.Company.Add(new Company()
            {
                Cemail           = "Mahmoud",
                Cname            = "MMM",
                Location         = "Giza",
                NumberOfEmplyees = 200,
                Password         = "******",
                CompanyInterests = companyInterests
            });
            context.Company.Add(new Company()
            {
                Cemail           = "Mahmoud",
                Cname            = "MMM",
                Location         = "Giza",
                NumberOfEmplyees = 200,
                Password         = "******",
                CompanyInterests = companyInterests
            });
            context.Company.Add(new Company()
            {
                Cemail           = "Mahmoud",
                Cname            = "MMM",
                Location         = "Giza",
                NumberOfEmplyees = 200,
                Password         = "******",
                CompanyInterests = companyInterests
            });

            var controller = new CompaniesController(context);
            var result     = controller.GetProducts() as TestCompanyDbSet;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Local.Count);
        }