PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/V2.2/trunk/RI/Desktop/StockTraderRI.Infrastructure.Tests/Converters/TransactionTypeToStringConverterFixture.cs

#
C# | 53 lines | 29 code | 8 blank | 16 comment | 0 complexity | a8cd35d9c017fcb7d815f3bdbe94825e MD5 | raw file
 1//===================================================================================
 2// Microsoft patterns & practices
 3// Composite Application Guidance for Windows Presentation Foundation and Silverlight
 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//===================================================================================
17using Microsoft.VisualStudio.TestTools.UnitTesting;
18using StockTraderRI.Infrastructure.Converters;
19
20namespace StockTraderRI.Infrastructure.Tests.Converters
21{
22    [TestClass]
23    public class TransactionTypeToStringConverterFixture
24    {
25        [TestMethod]
26        public void ShouldConvertTransactionTypeValuesToString()
27        {
28            TransactionTypeToStringConverter converter = new TransactionTypeToStringConverter();
29
30            var convertedValue = converter.Convert(TransactionType.Buy, null, null, null) as string;
31
32            Assert.IsNotNull(convertedValue);
33            Assert.AreEqual("BUY ", convertedValue);
34
35            convertedValue = converter.Convert(TransactionType.Sell, null, null, null) as string;
36
37            Assert.IsNotNull(convertedValue);
38            Assert.AreEqual("SELL ", convertedValue);
39        }
40
41        [TestMethod]
42        public void ShouldReturnNullIfValueToConvertIsNullOrNotTransactionType()
43        {
44            TransactionTypeToStringConverter converter = new TransactionTypeToStringConverter();
45
46            var convertedValue = converter.Convert(null, null, null, null) as string;
47            Assert.IsNull(convertedValue);
48
49            convertedValue = converter.Convert("NotATransactionType", null, null, null) as string;
50            Assert.IsNull(convertedValue);
51        }
52    }
53}