public void AddToShoppingList__BananAdd_WriteToFileIsCalled()
 {
     var banan = new ProductInfo("Banan");
     _shoppingList.ShoppingListItem = "Banan";
     _shoppingList.AddToShoppingListCommand.Execute(this);
     _shoppingList.User.Received(1).WriteToJsonFile();
 }
        public void AddToShoppingList__BananAdd_ShoppingListDataContainsBanan()
        {
            var banan = new ProductInfo("Banan");
            _shoppingList.ShoppingListItem = "Banan";
            _shoppingList.AddToShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData.Any(x => x.Name == banan.Name), Is.EqualTo(true));
        }
        public void ClearShoppingListCommand_ClearShoppingList_ShoppinglistEqualsIsEmpty()
        {
            var item = new ProductInfo("Test");
            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ClearShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData.Count, Is.EqualTo(0));
        }
        public void AddToShoppingList__BananAdd_ShoppingListDataNotContainsÆble()
        {
            var banan = new ProductInfo("æble");
            _uut.ShoppingListItem = "Banan";
            _uut.AddToShoppingListCommand.Execute(this);
            _uut.AddToShoppingListCommand.Execute(this);

            Assert.That(_uut.ShoppingListData.Any(x => x.Name == banan.Name), Is.EqualTo(false));
        }
Пример #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 DeleteFromShoppingListCommand_TwoItemsInListAndDeleteTest_ShoppinglistFirstPlaceEqualsItem2()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");
            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ShoppingListData.Add(item2);
            _shoppingList.SelectedItem = item;

            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData[0].Name, Is.EqualTo(item2.Name));
        }
        public void GeneratedShoppingListFromShoppingList_MakeANewListWithTwoProducts_NotInAStoreCountEquals0()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");

            _shoppingList.ShoppingListData.Add(item2);
            _shoppingList.ShoppingListData.Add(item);

            _shoppingList.GeneratedShoppingListCommand.Execute(this);

            Assert.That(_consumer.NotInAStore.Count, Is.EqualTo(0));
        }
        public void DeleteFromShoppingList_DeleteIsPressedWithBananAndKiwiInListAndBananSelected_BananRemoved()
        {
            ProductInfo Banan = new ProductInfo("Banan");
            ProductInfo Kiwi = new ProductInfo("Kiwi");
            _shoppingList.ShoppingListData.Add(Banan);
            _shoppingList.ShoppingListData.Add(Kiwi);

            _shoppingList.SelectedItem = Banan;
            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData.Any(x => x.Name == Banan.Name), Is.EqualTo(false));
        }
        public void DeleteFromShoppingList_DeleteIsPressedWithNoItemsInList_ErrorEqualsErrorMassage()
        {
            ProductInfo test = new ProductInfo("hej");

            _shoppingList.SelectedItem = test;
            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.Error, Is.EqualTo("Der er ikke tilføjet nogen produkter"));
            //Error, skal fixes
        }
        public void StoreChangedCommand_StoreChangedToTestTwo_StoreChangesToTestTwo()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");

            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ShoppingListData.Add(item2);

            _shoppingList.GeneratedShoppingListCommand.Execute(this);

            _generatedShoppingList.SelectedStoreIndex = 1;
            _generatedShoppingList.SelectedIndexGeneratedShoppingList = 0;
            _generatedShoppingList.StoreChangedCommand.Execute(this);

            Assert.That(_generatedShoppingList.ErrorStore, Is.EqualTo(""));
        }
 public void ReadFromJsonFile_ReadFromAFileThatDoesNotExist_ExceptionIscatchedAndListStillGotSameValues()
 {
     ObservableCollection<ProductInfo> productInfos = new ObservableCollection<ProductInfo>();
     ProductInfo test = new ProductInfo("test");
     productInfos.Add(test);
     _uut.ShoppingListData = productInfos;
     string path = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%"), "Documents") +
                   @"\Pristjek220" + @"\Shoppinglist.json";
     File.Delete(path);
     _uut.ReadFromJsonFile();
     Assert.That(_uut.ShoppingListData[0], Is.EqualTo(test));
 }
        public void DeleteFromShoppingList_DeleteIsPressedWithBananInList_BananRemoved()
        {
            ProductInfo Banan = new ProductInfo("Banan");

            _shoppingList.ShoppingListData.Add(Banan);

            _shoppingList.SelectedItem = Banan;
            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData, Is.Empty);
        }
 public void ReadFromJsonFile_FindWhichStoreSellsBanan_FunctionToGenerateListCalled()
 {
     ObservableCollection<ProductInfo> productInfos = new ObservableCollection<ProductInfo>();
     ProductInfo test = new ProductInfo("test");
     productInfos.Add(test);
     _uut.ShoppingListData = productInfos;
     _uut.WriteToJsonFile();
     _uut.ReadFromJsonFile();
     Assert.That(productInfos[0], Is.EqualTo(test));
 }
        public void GeneratedShoppingListFromShoppingList_MakeANewListWithThreeProducts_GeneratedshoppinglistCountEquals2()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");
            var item3 = new ProductInfo("NotInAStore");

            _shoppingList.ShoppingListData.Add(item2);
            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ShoppingListData.Add(item3);

            _shoppingList.GeneratedShoppingListCommand.Execute(this);

            Assert.That(_consumer.GeneratedShoppingListData.Count, Is.EqualTo(2));
        }
        public void DeleteFromShoppingListCommand_TwoItemsInListAndDeleteTest_ShoppinglistEqualsOne()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");
            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ShoppingListData.Add(item2);
            _shoppingList.SelectedItem = item;

            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData.Count, Is.EqualTo(1));
        }
        public void DeleteFromShoppingListCommand_DeleteTest_ShoppinglistEqualsIsEmpty()
        {
            var item = new ProductInfo("Test");
            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.SelectedItem = item;

            _shoppingList.DeleteFromShoppingListCommand.Execute(this);

            Assert.That(_shoppingList.ShoppingListData.Count, Is.EqualTo(0));
        }
        public void StoreChangedCommand_StoreChanged_ErrorMessage()
        {
            var item = new ProductInfo("Test");
            var item2 = new ProductInfo("Test2");

            _shoppingList.ShoppingListData.Add(item);
            _shoppingList.ShoppingListData.Add(item2);

            _shoppingList.GeneratedShoppingListCommand.Execute(this);

            _generatedShoppingList.SelectedStoreIndex = 1;
            _generatedShoppingList.SelectedIndexGeneratedShoppingList = 1;
            _generatedShoppingList.StoreChangedCommand.Execute(this);

            Assert.That(_generatedShoppingList.ErrorStore, Is.EqualTo(_generatedShoppingList.StoreNames[_generatedShoppingList.SelectedStoreIndex] + " har ikke produktet \"" +
                             _generatedShoppingList.GeneratedShoppingListData[_generatedShoppingList.SelectedIndexGeneratedShoppingList].ProductName +
                             "\" i deres sortiment."));
        }