public void USCoinViewModel_CoinColorFromCoinType()
        {
            //Arrange
            USCoinViewModel pennyVM    = new USCoinViewModel(new Penny());
            Brush           pennyBrush = new SolidColorBrush(Colors.Coral);
            Brush           returnedPennyBrush;

            USCoinViewModel dollarVM    = new USCoinViewModel(new DollarCoin());
            Brush           dollarBrush = new SolidColorBrush(Colors.Gold);
            Brush           returnedDollarBrush;


            USCoinViewModel nickelVM    = new USCoinViewModel(new Nickel());
            Brush           nickelBrush = new SolidColorBrush(Colors.Silver);
            Brush           returnedNickelBrush;

            //Act
            returnedPennyBrush  = pennyVM.CoinColor;
            returnedDollarBrush = dollarVM.CoinColor;
            returnedNickelBrush = nickelVM.CoinColor;

            //Assert
            Assert.AreEqual(pennyBrush.ToString(), returnedPennyBrush.ToString());
            Assert.AreEqual(dollarBrush.ToString(), returnedDollarBrush.ToString());
            Assert.AreEqual(nickelBrush.ToString(), returnedNickelBrush.ToString());
        }
예제 #2
0
        public CoinView(USCoin coin)
        {
            InitializeComponent();
            Coin = coin;
            USCoinViewModel viewModel = new USCoinViewModel(coin);

            this.DataContext = viewModel;
        }
        public void USCoinViewModel_FormattedCoinStringFromMonetaryValue()
        {
            //Arrange
            USCoinViewModel pennyVM = new USCoinViewModel(new Penny());
            string          pennyFormattedString = "1¢";
            string          returnedPennyString  = "";

            USCoinViewModel dollarVM = new USCoinViewModel(new DollarCoin());
            string          dollarFormattedString = "$1";
            string          returnedDollarString  = "";

            //Act
            returnedPennyString  = pennyVM.FormattedCoinString;
            returnedDollarString = dollarVM.FormattedCoinString;

            //Assert
            Assert.AreEqual(pennyFormattedString, returnedPennyString);
            Assert.AreEqual(dollarFormattedString, returnedDollarString);
        }