public void GetGiftCardViewModel_should_set_ParentCategoryId_and_ParentCategoryId_if_UrlContainsCategory(Database db)
        {
            //arrange
            string categoryIdTest   = "categoryIdTest";
            string categoryNameTest = "parentCategoryNameTest";

            Item fakeItem = BuildFakeItem(db, categoryNameTest);

            Category categoryTest = new Category(fakeItem);

            _catalogManagerMock.GetCategory(categoryIdTest).Returns(categoryTest);

            MockContexts(db, $"http://local/{categoryIdTest}/Id");

            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            rep.CurrentSiteContext.UrlContainsCategory = true;

            // act
            var product = rep.GetGiftCardViewModel(BuildFakeItem(db), new Rendering());

            // assert
            product.ParentCategoryId.Should().Be(categoryIdTest);
            product.ParentCategoryName.Should().Be(categoryNameTest);
        }
Example #2
0
        protected virtual void btnDelete_Click(object sender, EventArgs e)
        {
            var repo  = GiftCardRepository;
            var cards = GiftCardRepository.GetAll();

            foreach (var card in cards)
            {
                repo.Delete(card);
            }
            repo.Flush();
            BindResults();
        }
        public void GetGiftCardViewModel_should_take_ProductName_from_ItemsDisplayName(Database db)
        {
            //arrange
            string displayNameTest = "DisplayNameTest";

            MockContexts(db);

            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            // act
            var result = rep.GetGiftCardViewModel(BuildFakeItem(db, displayNameTest), new Rendering());

            // assert
            result.ProductName.Should().Be(displayNameTest);
        }
        public void GetGiftCardViewModel_should_set_CurrentProductItem_in_SiteContext(Database db)
        {
            //arrange
            Item fakeItem = BuildFakeItem(db);

            MockContexts(db);

            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            // act
            var product = rep.GetGiftCardViewModel(fakeItem, new Rendering());

            // assert
            rep.CurrentSiteContext.Items["CurrentProductViewModel"].Should().Be(product);
        }
        public void GetGiftCardViewModel_should_apply_GiftCardSpecialHandling_For_NonGiftCardItems(Database db)
        {
            //arrange
            Item fakeItem = BuildFakeItem(db);

            MockContexts(db);
            decimal testRating = new decimal(5.0);

            _catalogManagerMock.GetProductRating(fakeItem).Returns(testRating);
            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            // act
            var product = rep.GetGiftCardViewModel(fakeItem, new Rendering());

            // assert
            product.CustomerAverageRating.Should().Be(testRating);
        }
        public void GetGiftCardViewModel_should_return_ModelWithVarians_if_ItemHasChildren(Database db)
        {
            //arrange
            Item fakeItem = GetFakeItemWithChildren(db);

            MockContexts(db);

            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            // act
            var product = rep.GetGiftCardViewModel(fakeItem, new Rendering());

            // assert
            product.Variants.Count.Should().Be(GiftCardTestsConstants.ItemWithChildrenNumberOfChildren);
            product.Variants[0].Id.Should().Be(GiftCardTestsConstants.ItemWithChildrenFirstChildItemName);
            product.Variants[1].Id.Should().Be(GiftCardTestsConstants.ItemWithChildrenSecondChildItemName);
        }
        public void GetGiftCardViewModel_should_return_ProductViewModel_from_SiteContext_IfAvailable(Database db)
        {
            //arrange
            ProductViewModel testProduct = new ProductViewModel
            {
                ProductName = "testProductName",
                Description = "testProductDescription"
            };

            MockContexts(db);
            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            rep.CurrentSiteContext.Items["CurrentProductViewModel"] = testProduct;

            // act
            var result = rep.GetGiftCardViewModel(BuildFakeItem(db), new Rendering());

            //assert
            result.ProductName.Should().Be(testProduct.ProductName);
            result.Description.Should().Be(testProduct.Description);
        }
        [ItemWithChildrenDbData("22565422120")] // Gift Card ProductId
        public void GetGiftCardViewModel_should_apply_GiftCardSpecialHandling_For_GiftCardItem(Database db)
        {
            //arrange
            Item fakeGiftCardItem = GetFakeItemWithChildren(db);

            MockContexts(db);

            decimal adjustedPriceTest = new decimal(1.0);

            _catalogManagerMock.GetProductPrice(Arg.Any <IVisitorContext>(), Arg.Do <ProductViewModel>(p => p.Variants.ForEach(v => v.AdjustedPrice = adjustedPriceTest)));


            var rep = new GiftCardRepository(_accountManagerMock, _contactFactoryMock, _catalogManagerMock);

            // act
            var product = rep.GetGiftCardViewModel(fakeGiftCardItem, new Rendering());

            // assert
            product.GiftCardAmountOptions.Count.Should().Be(GiftCardTestsConstants.ItemWithChildrenNumberOfChildren);
            product.GiftCardAmountOptions[0].Key.Should().Be(GiftCardTestsConstants.ItemWithChildrenFirstChildItemName);
            product.GiftCardAmountOptions[0].Value.Should().Be(adjustedPriceTest);
            product.GiftCardAmountOptions[1].Key.Should().Be(GiftCardTestsConstants.ItemWithChildrenSecondChildItemName);
            product.GiftCardAmountOptions[1].Value.Should().Be(adjustedPriceTest);
        }
 public AggregateRepositoryTest()
 {
     _eventStore    = new Mock <IEventStore <GiftCard, Guid> >();
     _snapshotStore = new Mock <ISnapshotStore <GiftCard, Guid> >();
     _sut           = new GiftCardRepository(_eventStore.Object, _snapshotStore.Object);
 }