public void ChangeProductToAnotherStore_ProductDoesGetSoldInStore_Return1()
        {
            var storProdAndPrice = new StoreProductAndPrice() { Price = _hasA.Price, StoreName = _hasA.Store.StoreName, ProductName = _product.ProductName, Quantity = "1", Sum = _hasA.Price };
            _consumer.GeneratedShoppingListData.Add(storProdAndPrice);

            Assert.That(_consumer.ChangeProductToAnotherStore(_store1.StoreName, storProdAndPrice), Is.EqualTo(1));
        }
        public void ChangeProductToAnotherStore_ProductChangeToGetSoldInTestStore1_TotalSumChangedTo13()
        {
            var storProdAndPrice = new StoreProductAndPrice() { Price = _hasA.Price, StoreName = _hasA.Store.StoreName, ProductName = _product.ProductName, Quantity = "1", Sum = _hasA.Price };
            _consumer.GeneratedShoppingListData.Add(storProdAndPrice);
            _consumer.ChangeProductToAnotherStore(_store1.StoreName, storProdAndPrice);

            Assert.That(_consumer.TotalSum, Is.EqualTo(double.Parse("13,00", new CultureInfo("da-DK")).ToString("F2") + " kr"));
        }
        public void ChangeItemToAnotherStores_ChangeFromLidlToAldiWhenItemDontExistInAldi_returnsMinus1()
        {
            StoreProductAndPrice storeProductAndPrice = new StoreProductAndPrice() { Price = 2, ProductName = "Test", Sum = 4, Quantity = "2", StoreName = "Lidl" };
            _uut.GeneratedShoppingListData.Add(storeProductAndPrice);
            ProductAndPrice productAndPrice = null;
            _unitWork.Stores.FindProductInStore("Aldi", storeProductAndPrice.ProductName).Returns(productAndPrice);

            Assert.That(_uut.ChangeProductToAnotherStore("Aldi", storeProductAndPrice), Is.EqualTo(-1));
        }
        public void ClearGeneratedShoppingListData_AddOneItemToListCallClear_ItemHasBeenDeleted()
        {
            StoreProductAndPrice storeProductAndPriceItem = new StoreProductAndPrice();
            storeProductAndPriceItem.ProductName = "test";
            storeProductAndPriceItem.Price = 2;
            storeProductAndPriceItem.Quantity = "2";
            storeProductAndPriceItem.StoreName = "Aldi";
            storeProductAndPriceItem.Sum = 4;

            _uut.GeneratedShoppingListData.Add(storeProductAndPriceItem);
            _uut.ClearGeneratedShoppingListData();
            Assert.That(_uut.GeneratedShoppingListData.Count, Is.EqualTo(0));
        }
Esempio n. 5
0
        public void SendMail_send2listWithAnSingleItemInEach_SeeThatSmtpClientSendReceives1Call()
        {
            ObservableCollection<StoreProductAndPrice> storeProductAndPricesList = new ObservableCollection<StoreProductAndPrice>();
            StoreProductAndPrice storeProductAndPriceItem = new StoreProductAndPrice();
            storeProductAndPriceItem.ProductName = "test";
            storeProductAndPriceItem.Price = 2;
            storeProductAndPriceItem.Quantity = "2";
            storeProductAndPriceItem.StoreName = "Aldi";
            storeProductAndPriceItem.Sum = 4;
            storeProductAndPricesList.Add(storeProductAndPriceItem);

            ObservableCollection<ProductInfo> productInfoList = new ObservableCollection<ProductInfo>();
            ProductInfo ProductInfoItem = new ProductInfo("test");
            productInfoList.Add(ProductInfoItem);

            _mail.SendMail("*****@*****.**",storeProductAndPricesList , productInfoList, "22");
            _smtpClient.Received(1).Send(Arg.Any<MailMessage>());
        }
        public void ChangeItemToAnotherStores_ChangeFromLidlToAldiWhenItemExistInAldi_returns1()
        {
            StoreProductAndPrice storeProductAndPrice = new StoreProductAndPrice() {Price = 2, ProductName = "Test", Quantity = "2", StoreName = "Lidl"};
            _uut.GeneratedShoppingListData.Add(storeProductAndPrice);
            ProductAndPrice productAndPrice = new ProductAndPrice() {Price = 3, Name = "Aldi"};
            _unitWork.Stores.FindProductInStore("Aldi", storeProductAndPrice.ProductName).Returns(productAndPrice);

            List<StoreAndPrice> storeAndPriceList = new List<StoreAndPrice>();
            StoreAndPrice storeAndPrice = new StoreAndPrice{Price = 6, Name = _store.StoreName};
            storeAndPriceList.Add(storeAndPrice);

            _unitWork.Products.FindCheapestStoreForAllProductsWithSum(Arg.Any<List<ProductInfo>>())
                .Returns(storeAndPriceList);

            _uut.ShoppingListData.Add(new ProductInfo(_product.ProductName, "2"));

            Assert.That(_uut.ChangeProductToAnotherStore("Aldi", storeProductAndPrice), Is.EqualTo(1));
        }
        public void ErrorStore_ChangeStoreToStore0FromStore1WhereStore0DontHaveProductWait5Sek_ErrorStoreIsEmpty()
        {
            StoreProductAndPrice storeProductAndPrice = new StoreProductAndPrice()
            {
                ProductName = "Test",
                Price = 2,
                Quantity = "2",
                StoreName = "Store1"
            };

            _uut.ErrorStore = "Test";
            _uut.SelectedIndexGeneratedShoppingList = 0;
            _uut.SelectedStoreIndex = 0;
            _user.StoreNames = new List<string>();
            _user.GeneratedShoppingListData = new ObservableCollection<StoreProductAndPrice>() { storeProductAndPrice };
            _uut.StoreNames.Add("Store0");
            _uut.StoreNames.Add("Store1");
            _uut.GeneratedShoppingListData.Add(storeProductAndPrice);
            _user.ChangeProductToAnotherStore("Store0", storeProductAndPrice).Returns(0);

            _uut.StoreChangedCommand.Execute(this);
            Assert.That(_uut.ErrorStore, Is.EqualTo("Store0 har ikke produktet \"Test\" i deres sortiment."));
        }
        public void ChangeProductToAnotherStore_ProductDoesNotGetSoldInOtherStore_ReturnMinus1()
        {
            var storProdAndPrice = new StoreProductAndPrice() { Price = _hasA.Price, StoreName = _hasA.Store.StoreName, ProductName = _product.ProductName, Quantity = "1", Sum = _hasA.Price };

            Assert.That(_consumer.ChangeProductToAnotherStore("NoStore", storProdAndPrice), Is.EqualTo(-1));
        }
        public void StoreChanged_ChangeStoreToStore0FromStore1_ErrorStoreIsEmptyString()
        {
            StoreProductAndPrice storeProductAndPrice = new StoreProductAndPrice()
            {
                ProductName = "Test",
                Price = 2,
                Quantity = "2",
                StoreName = "Store1"
            };

            _uut.ErrorStore = "Test";
            _uut.SelectedIndexGeneratedShoppingList = 0;
            _uut.SelectedStoreIndex = 0;
            _user.StoreNames = new List<string>();
            _user.GeneratedShoppingListData = new ObservableCollection<StoreProductAndPrice>() { storeProductAndPrice };
            _uut.StoreNames.Add("Store0");
            _uut.StoreNames.Add("Store1");
            _uut.GeneratedShoppingListData.Add(storeProductAndPrice);
            _user.ChangeProductToAnotherStore("Store0", storeProductAndPrice).Returns(1);

            _uut.StoreChangedCommand.Execute(this);
            Assert.That(_uut.ErrorStore, Is.EqualTo(""));
        }
Esempio n. 10
0
        /// <summary>
        ///     Change the product to another store if the product exist in that store
        /// </summary>
        /// <param name="storeName"></param>
        /// <param name="product"></param>
        /// <returns>1 if the product has been changed to another store and -1 if the other store does not have the product</returns>
        public int ChangeProductToAnotherStore(string storeName, StoreProductAndPrice product)
        {
            var productIndex = GeneratedShoppingListData.IndexOf(product);
            ProductAndPrice productAndPrice;
            if ((productAndPrice = _unit.Stores.FindProductInStore(storeName, product.ProductName)) == null) return -1;
            var newSum = productAndPrice.Price*double.Parse(GeneratedShoppingListData[productIndex].Quantity);
            GeneratedShoppingListData[productIndex] = new StoreProductAndPrice
            {
                Price = productAndPrice.Price,
                ProductName = GeneratedShoppingListData[productIndex].ProductName,
                Quantity = GeneratedShoppingListData[productIndex].Quantity,
                StoreName = storeName,
                Sum = newSum
            };
            var sum = CalculateSumForGeneratedList();
            StoreAndPrice diff;
            if ((diff = FindDifferenceforProducts()) != null)
                MoneySaved = (diff.Price - sum).ToString("F2", CultureInfo.CurrentCulture) + " kr";

            return 1;
        }