Click here to Skip to main content
15,887,746 members
Articles / Programming Languages / Visual Basic

Simulating Stored Procedures in Microsoft Access using Enterprise Library Application Blocks

Rate me:
Please Sign up or sign in to vote.
3.46/5 (12 votes)
25 Jul 2005MIT6 min read 98.3K   1.1K   37  
Simulating stored procedures in Microsoft Access using Enterprise Library Application Blocks.
//===============================================================================
// Microsoft patterns & practices Enterprise Library
// Data Access Application Block
//===============================================================================
// Copyright � Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

#if   UNIT_TESTS
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;

namespace Microsoft.Practices.EnterpriseLibrary.Data.Configuration.Tests
{
    [TestFixture]
    public class ParameterDataFixture
    {
        private static readonly string name = "MyName";
        private static readonly string val = "MyVal";

        private static readonly string xmlString =
            "<parameter name=\"" + name + "\" value=\"" + val + "\" xmlns=\"" + DatabaseSettings.ConfigurationNamespace + "\" />";

        private static readonly string xmlStringSensitive =
            "<parameter name=\"" + name + "\" value=\"" + val + "\" isSensitive=\"true\" xmlns=\"" + DatabaseSettings.ConfigurationNamespace + "\" />";

        private ParameterData parameter;

        [TestFixtureSetUp]
        public void Initialize()
        {
            XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlString));
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(ParameterData));
            parameter = xmlSerializer.Deserialize(xmlReader) as ParameterData;
        }

        [Test]
        public void DeserializeTest()
        {
            Assert.IsNotNull(parameter);
        }

        [Test]
        public void DatabaseName()
        {
            Assert.AreEqual(name, parameter.Name);
        }

        [Test]
        public void Type()
        {
            Assert.AreEqual(val, parameter.Value);
        }

        [Test]
        public void Sensitive()
        {
            XmlTextReader xmlReader = new XmlTextReader(new StringReader(xmlStringSensitive));
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(ParameterData));
            ParameterData sensitiveParameter = xmlSerializer.Deserialize(xmlReader) as ParameterData;
            Assert.AreEqual(true, sensitiveParameter.IsSensitive);
        }
    }
}

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Software Developer (Senior) http://ADefWebserver.com
United States United States
Michael Washington is a Microsoft MVP. He is a ASP.NET and
C# programmer.
He is the founder of
AiHelpWebsite.com,
LightSwitchHelpWebsite.com, and
HoloLensHelpWebsite.com.

He has a son, Zachary and resides in Los Angeles with his wife Valerie.

He is the Author of:

Comments and Discussions