Exemple #1
0
        public void UpdatePassword_UserWithNoPassword_PasswordCanBeVerified(string password, bool expectedResult)
        {
            var user   = new User(mMembershipFakeFactory.UserWithoutPassword);
            var result = manager.CallProtectedUpdatePassword(user, password);

            CMSAssert.All(() => Assert.AreEqual(expectedResult, result.Succeeded),
                          () => Assert.IsTrue(manager.CallProtectedVerifyPassword(user, password)));
        }
Exemple #2
0
        public void RemoveLoginAsync_NonExistingLogin_NoExceptionNoLoginRemoved()
        {
            var user  = new User(mMembershipFakeFactory.UserExternal);
            var login = new UserLoginInfo("fakeProvider", "fakeKey");

            CMSAssert.All(
                () => Assert.DoesNotThrow(() => mUserStore.RemoveLoginAsync(user, login).Wait()),
                async() => Assert.AreEqual(1, (await mUserStore.GetLoginsAsync(user)).Count));
        }
        public void GetPaymentMethod_DisabledPaymentMethod_ReturnsPaymentMethod()
        {
            var paymentMethod = mRepository.GetById(DISABLED_PAYMENTMETHOD_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(paymentMethod, "Returned null for an existing disabled payment option."),
                () => Assert.AreEqual(DISABLED_PAYMENTMETHOD_ID, paymentMethod.PaymentOptionID, "Incorrect payment option returned.")
                );
        }
 protected void AssertPrice(ProductPrice calculatedprice, ProductPrice expectedPrice)
 {
     CMSAssert.All(
         () => Assert.AreEqual(expectedPrice.Discount, calculatedprice.Discount, "Discount {0} does not match the expected value {1}.", new object[] { calculatedprice.Discount, expectedPrice.Discount }),
         () => Assert.AreEqual(expectedPrice.ListPrice, calculatedprice.ListPrice, "ListPrice {0} does not match the expected value {1}.", new object[] { calculatedprice.ListPrice, expectedPrice.ListPrice }),
         () => Assert.AreEqual(expectedPrice.Price, calculatedprice.Price, "Price {0} does not match the expected value {1}.", new object[] { calculatedprice.Price, expectedPrice.Price }),
         () => Assert.AreEqual(expectedPrice.Tax, calculatedprice.Tax, "Tax {0} does not match the expected value {1}.", new object[] { calculatedprice.Tax, expectedPrice.Tax })
         );
 }
Exemple #5
0
        public void GetOder_ExistingOrder_ReturnsOrder()
        {
            var order = mRepository.GetById(ORDER_FIRST_SITE_ID1);

            CMSAssert.All(
                () => Assert.IsNotNull(order, "Order not found."),
                () => Assert.AreEqual(ORDER_FIRST_SITE_ID1, order.OrderID, "Incorrect order returned.")
                );
        }
Exemple #6
0
            public void Equals_CommutativeProperty_SameResults()
            {
                var constraint1 = SizeConstraint.Size(100, 200);
                var constraint2 = SizeConstraint.Size(100, 200);

                CMSAssert.All(
                    () => Assert.That(constraint1.Equals(constraint2), Is.True),
                    () => Assert.That(constraint2.Equals(constraint1), Is.True));
            }
Exemple #7
0
        public void GetProductVariants_ExistingSKUWithVariants_ReturnsAllVariants()
        {
            var variants = mRepository.GetByProductId(PARENT_SKU_WITHVARIANTS);

            CMSAssert.All(
                () => Assert.IsNotNull(variants, "Returned null for product with variants."),
                () => Assert.AreEqual(3, variants.Count(), "Returned incorrect number of variants.")
                );
        }
Exemple #8
0
        public void GetShippingOption_DisabledShippingOption_ReturnsShippingOption()
        {
            var shippingOption = mRepository.GetById(DISABLED_SHIPPINGOPTION_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(shippingOption, "Returned null for an existing disabled shipping option."),
                () => Assert.AreEqual(DISABLED_SHIPPINGOPTION_ID, shippingOption.ShippingOptionID, "Incorrect shipping option returned.")
                );
        }
Exemple #9
0
        public void GetCustomerAddresses_WithAddresses_ReturnsAddresses()
        {
            var addresses = mRepository.GetByCustomerId(CUSTOMER_WITHADDRESS_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(addresses, "Returned null instead of a collection of addresses."),
                () => Assert.AreEqual(2, addresses.Count(), "Wrong number of addresses returned.")
                );
        }
Exemple #10
0
        public async Task AddToRoleAsync_UserIsNotInRole_UserRoleInfoCreated()
        {
            var user = new User(mMembershipFakeFactory.UserEnabledWithEmail);
            await mUserStore.AddToRoleAsync(user, MembershipFakeFactory.ROLE_MEMBER);

            CMSAssert.All(
                () => Assert.AreEqual(1, UserRoleInfoProvider.GetUserRoles().Count),
                () => Assert.IsNotNull(UserRoleInfoProvider.GetUserRoleInfo(user.Id, mMembershipFakeFactory.MemberRole.RoleID)));
        }
Exemple #11
0
            public void Size_ValidBothArguments_SetsWidthAndHeightProperties()
            {
                var constraint = SizeConstraint.Size(100, 200);

                CMSAssert.All(
                    () => Assert.That(constraint.WidthComponent, Is.EqualTo(100)),
                    () => Assert.That(constraint.HeightComponent, Is.EqualTo(200)),
                    () => Assert.That(constraint.MaxWidthOrHeightComponent, Is.EqualTo(0)));
            }
Exemple #12
0
        public void GetProductVariant_ExistingEnabledVariant_ReturnsVariant()
        {
            var variant = mRepository.GetById(VARIANT_SKU_ID1);

            CMSAssert.All(
                () => Assert.IsNotNull(variant, "No object returned for an existing enabled variant."),
                () => Assert.AreEqual(VARIANT_SKU_ID1, variant.VariantSKUID)
                );
        }
Exemple #13
0
        public void GetVariantOptionCategories_ExistingSKUWithoutCategories_ReturnsEmptyCollection()
        {
            var categories = mRepository.GetVariantOptionCategories(PARENT_SKU_WITHOUTVARIANTS);

            CMSAssert.All(
                () => Assert.IsNotNull(categories, "Returned null instead of an empty collection."),
                () => Assert.IsEmpty(categories, "Returned option categories for a product without variants.")
                );
        }
Exemple #14
0
        public void GetVariantOptionCategories_NonExistentSKU_ReturnsEmptyCollection()
        {
            var categories = mRepository.GetVariantOptionCategories(NONEXISTENT_SKU_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(categories, "Returned null instead of an empty collection."),
                () => Assert.IsEmpty(categories, "Returned option categories for non-existent SKU")
                );
        }
Exemple #15
0
        public void GetProductVariants_ExistingSKUWithoutVariants_ReturnsEmptyCollection()
        {
            var variants = mRepository.GetByProductId(PARENT_SKU_WITHOUTVARIANTS);

            CMSAssert.All(
                () => Assert.IsNotNull(variants, "Returned null instead of an empty collection."),
                () => Assert.IsEmpty(variants, "Returned variants for a product without variant")
                );
        }
Exemple #16
0
        public void GetProductVariants_NonExistentSKU_ReturnsEmptyCollection()
        {
            var variants = mRepository.GetByProductId(NONEXISTENT_SKU_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(variants, "Returned null instead of an empty collection."),
                () => Assert.IsEmpty(variants, "Returned variants for a product without variant")
                );
        }
Exemple #17
0
            public void Width_ValidArgument_SetsWidthComponentProperty()
            {
                var constraint = SizeConstraint.Width(100);

                CMSAssert.All(
                    () => Assert.That(constraint.WidthComponent, Is.EqualTo(100)),
                    () => Assert.That(constraint.HeightComponent, Is.EqualTo(0)),
                    () => Assert.That(constraint.MaxWidthOrHeightComponent, Is.EqualTo(0)));
            }
Exemple #18
0
        public void GetCustomerOrders_NonExistingCustomer_ReturnsEmptyList()
        {
            var orders = mRepository.GetByCustomerId(NON_EXISTING_CUSTOMER_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(orders),
                () => Assert.IsEmpty(orders, "Orders returned for non-existing customer.")
                );
        }
Exemple #19
0
            public void Register_SingleCall_PreviewFilterRegistered()
            {
                PreviewGlobalFilters.Register();

                CMSAssert.All(
                    () => Assert.That(GlobalFilters.Filters.Count, Is.EqualTo(1)),
                    () => Assert.That(GlobalFilters.Filters.First().Instance, Is.TypeOf(typeof(PreviewOutputCacheFilter)))
                    );
            }
Exemple #20
0
            public void NotEqualOperator_CommutativeProperty_SameResults()
            {
                var constraint1 = SizeConstraint.Size(100, 200);
                var constraint2 = SizeConstraint.Size(100, 200);

                CMSAssert.All(
                    () => Assert.That(constraint1 != constraint2, Is.False),
                    () => Assert.That(constraint2 != constraint1, Is.False));
            }
Exemple #21
0
        public void GetCustomerOrders_ExistingCustomerWithoutTopNParameter_ReturnsAllOrdersFromCurrentSite()
        {
            var orders = mRepository.GetByCustomerId(CUSTOMER_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(orders),
                () => Assert.IsNotEmpty(orders, "No orders found for customer."),
                () => Assert.AreEqual(2, orders.Count(), "Orders count is not 2 as expected.")
                );
        }
Exemple #22
0
        public void Search_ValidSearchOptions_ReturnsNoData()
        {
            var searchResults = PageSearch();
            var results       = searchResults.Result;

            CMSAssert.All(
                // Test that results.Items is an empty collection, cannot be null.
                () => Assert.That(results.Items, Is.Empty),
                () => Assert.AreEqual(results.TotalNumberOfResults, 0));
        }
        public async Task RoleDeletion_OneRoleIsCreatedWithID_AfterDeletingRole_NoRoleInfoExists()
        {
            int idToBeDeleted = role.Id;

            await store.DeleteAsync(role);

            CMSAssert.All(
                () => Assert.AreNotEqual(0, idToBeDeleted),
                () => Assert.AreEqual(0, RoleInfoProvider.GetRoles().Count));
        }
Exemple #24
0
        public void GetShippingOptions_ReturnsAllEnabledOptions()
        {
            var shippingOptions = mRepository.GetAllEnabled();

            CMSAssert.All(
                () => Assert.IsNotNull(shippingOptions, "No shipping option returned."),
                () => Assert.IsNotEmpty(shippingOptions, "No enabled shipping options found."),
                () => Assert.AreEqual(2, shippingOptions.Count(), "Wrong number of shipping options returned.")
                );
        }
        public void GetPaymentMethod_GlobalPaymentMethod_GlobalEnabled_ReturnsPaymentMethod()
        {
            EnableGlobalMethods(true);
            var paymentMethod = mRepository.GetById(GLOBAL_PAYMENTMETHOD_ID);

            CMSAssert.All(
                () => Assert.IsNotNull(paymentMethod, "Returned null for an existing enabled global payment option."),
                () => Assert.AreEqual(GLOBAL_PAYMENTMETHOD_ID, paymentMethod.PaymentOptionID, "Incorrect payment option returned.")
                );
        }
Exemple #26
0
        public async Task PasswordSignInAsync_IncorrectPassword_UserNotSignedIn(string userName, string password)
        {
            var user = UserInfoProvider.GetUserInfo(userName);

            var result = await mSignInManager.PasswordSignInAsync(user.UserName, "incorrectPassword", false, false);

            CMSAssert.All(
                () => Assert.AreEqual(SignInStatus.Failure, result),
                () => Assert.IsNull(mOwinContext.Authentication.AuthenticationResponseGrant));
        }
        public void AddItem_ContainsCorrectItem(int units)
        {
            var cart = CreateCartWithItem(Factory.SKUAvailable.SKUID, units);
            var item = cart.Items.FirstOrDefault();

            CMSAssert.All(
                () => Assert.That(cart.Items.Count() == 1, "Wrong number of products in shopping cart", null),
                () => Assert.AreEqual(item.Name, Factory.SKUAvailable.SKUName, "Item name does not match", null),
                () => Assert.AreEqual(item.Units, units, "Invalid number of item units", null)
                );
        }
Exemple #28
0
        public void SetAsPaid_OrderIsPaid()
        {
            var order = CreateOrderFromNewCart();

            order.SetAsPaid();

            CMSAssert.All(
                () => Assert.That(order.OriginalOrder.OrderIsPaid),
                () => Assert.That(order.IsPaid)
                );
        }
Exemple #29
0
        public void UpdatePassword_PBKDF2PasswordHashMethod_PasswordCanBeVerified()
        {
            SettingsKeyInfoProvider.SetValue("CMSPasswordFormat", 0, "pbkdf2");

            var user         = new User(mMembershipFakeFactory.UserWithPassword);
            var result       = manager.CallProtectedUpdatePassword(user, MembershipFakeFactory.TEST_PASSWORD);
            var passwordHash = ValidationHelper.GetString(UserInfoProvider.GetUserInfo(user.Id).GetValue("UserPassword"), string.Empty);

            CMSAssert.All(() => Assert.IsTrue(SecurityHelper.VerifyPBKDF2Hash(MembershipFakeFactory.TEST_PASSWORD, passwordHash)),
                          () => Assert.IsTrue(manager.CallProtectedVerifyPassword(user, MembershipFakeFactory.TEST_PASSWORD)));
        }
Exemple #30
0
        public void UpdatePassword_VariousPasswordHashMethods_PasswordCanBeVerified(string hashMethod, string password)
        {
            SettingsKeyInfoProvider.SetValue("CMSPasswordFormat", 0, hashMethod);

            var user         = new User(mMembershipFakeFactory.UserWithPassword);
            var result       = manager.CallProtectedUpdatePassword(user, password);
            var passwordHash = UserInfoProvider.GetUserInfo(user.Id).GetValue("UserPassword");

            CMSAssert.All(() => Assert.AreEqual(UserInfoProvider.GetPasswordHash(password, hashMethod, user.GUID.ToString()), passwordHash),
                          () => Assert.IsTrue(manager.CallProtectedVerifyPassword(user, password)));
        }