public void passwordEncryptionService_PasswordIsEncrypted() { //Arrange string password = "******"; //Act var result = passwordEncryptionService.SetPassword(password); //Assert Assert.AreNotEqual(result, password); }
internal bool LoadData(ECommerceContextDb context, bool isUnitTest = false) { try { if (context.Categories.Count() == 0) { var listCategories = new List <Category>() { new Category { Id = 1, CategoryName = "New Releases" }, new Category { Id = 2, CategoryName = "Men" }, new Category { Id = 3, CategoryName = "Women" }, new Category { Id = 4, CategoryName = "Unisex" }, }; listCategories.ForEach(p => context.Categories.Add(p)); context.SaveChanges(); } if (context.Brands.Count() == 0) { var listBrands = new List <Brand>() { new Brand { Id = 1, BrandName = "Nike" }, new Brand { Id = 2, BrandName = "Adidas" }, new Brand { Id = 3, BrandName = "Onnit" } }; listBrands.ForEach(p => context.Brands.Add(p)); context.SaveChanges(); } if (context.OrderStatus.Count() == 0) { var listOrderStatus = new List <OrderStatus>() { new OrderStatus { Id = 1, Status = "Ongoing" }, new OrderStatus { Id = 2, Status = "Completed" }, new OrderStatus { Id = 3, Status = "Abandoned" } }; listOrderStatus.ForEach(p => context.OrderStatus.Add(p)); context.SaveChanges(); } if (context.ProductTypes.Count() == 0) { var listProductType = new List <ProductType>() { new ProductType { Id = 1, ProductTypeName = "Shoes" }, new ProductType { Id = 2, ProductTypeName = "Headwear" }, new ProductType { Id = 3, ProductTypeName = "T-Shirts" } }; listProductType.ForEach(p => context.ProductTypes.Add(p)); context.SaveChanges(); } if (!isUnitTest) { if (context.Products.Count() == 0) { var listProducts = new List <Product>() { new Product { Id = 1, Brand = context.Brands.SingleOrDefault(p => p.Id == 1), HeroImage = GetHeroImage(1), HeroTitle = "Nike Air Zoom Pegasus 37", Title = "Nike Air Zoom Pegasus 37", Description = GetDescription(1), CategoryId = 1, Gender = GenderEnum.Male.ToString(), Images = GetImages(1), ProductType = context.ProductTypes.SingleOrDefault(p => p.Id == 1), Sizes = GetProductSizes(1), Price = 200 }, new Product { Id = 2, Brand = context.Brands.SingleOrDefault(p => p.Id == 1), HeroImage = GetHeroImage(2), HeroTitle = "Nike Mercurial Superfly 7 Elite MDS FG", Title = "Nike Mercurial Superfly 7 Elite MDS FG", Description = GetDescription(2), CategoryId = 2, Gender = GenderEnum.Male.ToString(), Images = GetImages(2), ProductType = context.ProductTypes.SingleOrDefault(p => p.Id == 1), Sizes = GetProductSizes(2), Price = 370 }, new Product { Id = 3, Brand = context.Brands.SingleOrDefault(p => p.Id == 1), HeroImage = GetHeroImage(3), HeroTitle = "Nike Zoom Pegasus Turbo 2", Title = "Nike Zoom Pegasus Turbo 2", Description = GetDescription(3), CategoryId = 3, Gender = GenderEnum.Male.ToString(), Images = GetImages(3), ProductType = context.ProductTypes.SingleOrDefault(p => p.Id == 1), Sizes = GetProductSizes(3), Price = 260 }, //TODO : Add these later - let's just get the site up and running with data //new Product { Id = 4, Brand = context.Brands.Where(p => p.Id == 2).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(4) }, //new Product { Id = 5, Brand = context.Brands.Where(p => p.Id == 2).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(5) }, //new Product { Id = 6, Brand = context.Brands.Where(p => p.Id == 2).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(6) }, //new Product { Id = 7, Brand = context.Brands.Where(p => p.Id == 3).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(7) }, //new Product { Id = 8, Brand = context.Brands.Where(p => p.Id == 3).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(8) }, //new Product { Id = 9, Brand = context.Brands.Where(p => p.Id == 3).SingleOrDefault(), HeroImage = "", HeroTitle = "", Images = GetImages(9) }, }; listProducts.ForEach(p => context.Products.Add(p)); context.SaveChanges(); } } if (context.Roles.Count() == 0) { var listRoles = new List <Role>() { new Role { Id = 1, RoleName = "Administrator" }, new Role { Id = 2, RoleName = "SuperUser" }, new Role { Id = 3, RoleName = "User" } }; listRoles.ForEach(p => context.Roles.Add(p)); context.SaveChanges(); } var passwordEncryptionService = new PasswordEncryptionService(); if (context.Users.Count() == 0) { var listUsers = new List <User>() { new User { Id = 1, Email = "*****@*****.**", CreatedDate = DateTime.Now, DateOfBirth = DateTime.Now, FirstName = "Admin", LastName = "ECommerce", IsSubscribed = false, Password = passwordEncryptionService.SetPassword("thisisencrypted"), RoleId = 1 }, new User { Id = 2, Email = "*****@*****.**", CreatedDate = DateTime.Now, DateOfBirth = DateTime.Now, FirstName = "Superuser", LastName = "ECommerce", IsSubscribed = false, Password = passwordEncryptionService.SetPassword("thisisencrypted"), RoleId = 2 } }; listUsers.ForEach(p => context.Users.Add(p)); context.SaveChanges(); } return(true); } catch (Exception exception) { throw exception; } }