PageRenderTime 22ms CodeModel.GetById 9ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/V1/trunk/Source/StockTraderRI/StockTraderRI.Infrastructure.Tests/Converters/TwoDecimalPlaceConverterFixture.cs

#
C# | 58 lines | 34 code | 8 blank | 16 comment | 0 complexity | 913a9a7097ec59963eb4660f2c45f2d7 MD5 | raw file
 1//===============================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation
 4//===============================================================================
 5// Copyright (c) Microsoft Corporation.  All rights reserved.
 6// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
 7// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
 8// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 9// FITNESS FOR A PARTICULAR PURPOSE.
10//===============================================================================
11// The example companies, organizations, products, domain names,
12// e-mail addresses, logos, people, places, and events depicted
13// herein are fictitious.  No association with any real company,
14// organization, product, domain name, email address, logo, person,
15// places, or events is intended or should be inferred.
16//===============================================================================
17
18using System;
19using System.Collections.Generic;
20using System.Linq;
21using System.Text;
22using Microsoft.VisualStudio.TestTools.UnitTesting;
23using StockTraderRI.Infrastructure.Converters;
24
25namespace StockTraderRI.Infrastructure.Tests.Converters
26{
27	[TestClass]
28	public class TwoDecimalPlaceConverterFixture
29	{
30        [TestMethod]
31        public void TwoDecimalPlaceConverterRoundsToTwoDecimals()
32        {
33            TwoDecimalPlaceConverter converter = new TwoDecimalPlaceConverter();
34            object value = converter.Convert(123.45678M, typeof(decimal), 2, null);
35            
36            Assert.AreEqual<decimal>(123.46M, Convert.ToDecimal(value));
37        }
38
39        [ExpectedException(typeof(ArgumentException))]
40        [TestMethod]
41        public void OnlyAcceptsDecimalValueArgument()
42        {
43            TwoDecimalPlaceConverter converter = new TwoDecimalPlaceConverter();
44            converter.Convert("hello", null, 2, null);
45
46        }
47        
48        [ExpectedException(typeof(ArgumentException))]
49        [TestMethod]
50        public void OnlyAcceptsIntegerNumDigitsArgument()
51        {
52            TwoDecimalPlaceConverter converter = new TwoDecimalPlaceConverter();
53            converter.Convert(123.4467M, null, "foo", null);
54
55        }
56	
57	}
58}