public void SaveableCurrenyRepo_Saving_Load()
        {
            List <ICoin> RepoCoins()
            {
                ICoin p  = new Penny();
                ICoin h  = new HalfDollar();
                ICoin dc = new DollarCoin();
                ICoin q  = new Quarter();
                ICoin d  = new Dime();
                ICoin n  = new Nickel();

                List <ICoin> Repo_list = new List <ICoin>
                {
                    { p }
                };

                return(Repo_list);
            }

            //Arrange
            List <ICoin> loadedCoins;

            loadedCoins = RepoCoins();

            //Act
            repo.Save(loadedCoins);
            repo.Load();


            //Assert
            Assert.AreEqual(repo.Coins.Count, loadedCoins.Count);

            CollectionAssert.AreEqual(repo.Coins, loadedCoins);
        }
        private void LoadCommand()
        {
            SerializableCurrencyRepo loadedRepo = null;

            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".bs";
            dialog.Filter     = $"{StaticInformation.FileExtensionName} Files (*{StaticInformation.FileExtension})|*{StaticInformation.FileExtension}";

            Nullable <bool> result = dialog.ShowDialog();

            if (result == true)
            {
                string filename = dialog.FileName;
                loadedRepo = SaveAndLoadUtility.Load <SerializableCurrencyRepo>(filename);

                USCurrencyRepo repo  = new USCurrencyRepo();
                List <ICoin>   coins = new List <ICoin>();
                foreach (SerializableCoin coin in loadedRepo.Coins)
                {
                    USCoin usCoin;
                    string name = coin.Name.Replace("US ", "");
                    switch (name)
                    {
                    case "Penny":
                        usCoin = new Penny();
                        break;

                    case "Nickel":
                        usCoin = new Nickel();
                        break;

                    case "Dime":
                        usCoin = new Dime();
                        break;

                    case "Quarter":
                        usCoin = new Quarter();
                        break;

                    case "Half Dollar":
                        usCoin = new HalfDollar();
                        break;

                    case "Dollar Coin":
                        usCoin = new DollarCoin();
                        break;

                    default:
                        usCoin = new Penny();
                        break;
                    }

                    coins.Add(usCoin);
                }

                StaticInformation.MainRepo.Coins = coins;
                RefreshAll();
            }
        }
        public void HalfDollarAbout()
        {
            //Arrange
            h = new HalfDollar();
            //Act

            //Assert
            Assert.AreEqual("US Half Dollar is from 2017. It is worth $0.50. It was made in Denver.", h.About());
        }
        public void HalfDollarMonetaryValue()
        {
            //Arrange
            h = new HalfDollar();
            //Act

            //Assert
            Assert.AreEqual(.50, h.MonetaryValue);
        }
 public USCurrencyRepoTests()
 {
     repo       = new CurrencyRepo();
     penny      = new Penny();
     nickel     = new Nickel();
     dime       = new Dime();
     quarter    = new Quarter();
     dollarCoin = new DollarCoin();
     halfDollar = new HalfDollar();
 }
        private void ButtonAddCoin_Click(object sender, RoutedEventArgs e)
        {
            Coin tempC = new Penny();

            switch (CoinList.SelectionBoxItem)
            {
            case "Penny":
            {
                tempC = new Penny();
                break;
            }

            case "Nickel":
            {
                tempC = new Nickel();
                break;
            }

            case "Dime":
            {
                tempC = new Dime();
                break;
            }

            case "Quarter":
            {
                tempC = new Quarter();
                break;
            }

            case "Half Dollar":
            {
                tempC = new HalfDollar();
                break;
            }

            case "Dollar Coin":
            {
                tempC = new DollarCoin();
                break;
            }
            }

            repo.AddCoin(tempC);


            ViewModelRepo    = new ViewModelCreateCurrencyRepo(repo);
            this.DataContext = ViewModelRepo;

            string value = Convert.ToString(repo.TotalValue());

            labelRepoValueDisplay.Content = "$" + value;
        }
        public void HalfDollarConstructor()
        {
            //Arrange
            HalfDollar philli;

            h = new HalfDollar();

            //Act
            philli = new HalfDollar(USCoinMintMark.P);
            //Assert
            //Current Year is default year
            Assert.AreEqual(USCoinMintMark.D, h.MintMark);
            Assert.AreEqual(System.DateTime.Now.Year, h.Year);
            Assert.AreEqual(System.DateTime.Now.Year, philli.Year);
            Assert.AreEqual(USCoinMintMark.P, philli.MintMark);
        }
        //public void USCoinSerialize()
        //{
        //    //Arrange
        //    List<ICoin> coinList, readCoinList;
        //    coinList = getCoinList();
        //    //Act

        //    IFormatter formatter = new BinaryFormatter();
        //    Stream stream = new MemoryStream();
        //    formatter.Serialize(stream, coinList);
        //    stream.Position = 0;
        //    readCoinList = (List<ICoin>)formatter.Deserialize(stream);
        //    //Assert
        //    foreach (Coin c in coinList)
        //    {
        //        Assert.IsTrue(c is ISerializable);
        //    }
        //    CollectionAssert.AreEqual(coinList, readCoinList);

        //}

        private List <ICoin> getCoinList()
        {
            ICoin n    = new Nickel();
            ICoin pen  = new Penny();
            ICoin q    = new Quarter();
            ICoin d    = new Dime();
            ICoin hd   = new HalfDollar();
            ICoin doll = new DollarCoin();

            List <ICoin> coinList = new List <ICoin>
            {
                { doll },
                { hd },
                { q },
                { d },
                { n },
                { pen }
            };

            return(coinList.OrderByDescending(c => c.MonetaryValue).ToList());
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Coininator 9000");

            //Make some Coins
            Nickel     n    = new Nickel();
            Penny      p    = new Penny();
            Quarter    q    = new Quarter();
            Dime       d    = new Dime();
            HalfDollar hd   = new HalfDollar();
            DollarCoin doll = new DollarCoin();

            Console.WriteLine("List of US Coins\n");

            Console.WriteLine(n.About());
            Console.WriteLine(p.About());
            Console.WriteLine(q.About());
            Console.WriteLine(d.About());
            Console.WriteLine(hd.About());
            Console.WriteLine(doll.About());


            Console.ReadKey();
        }