Пример #1
0
        public void Fails_On_MisMatch_Column_Manual_Map()
        {
            const string connectionString = "Data Source=(local);Initial Catalog=BulkWriterTest;Integrated Security=SSPI";
            string       tableName        = AutoDiscover.TableName <MyTestClass>(false);

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[Name] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            var mapping = MapBuilder
                          .MapAllProperties <MyTestClass>()
                          .MapProperty(x => x.Name, x => x.ToColumnName("MisMatchColumn"));

            IEnumerable <PropertyMapping> propertyMappings = ((MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            try
            {
                AutoDiscover.Mappings(connectionString, tableName, propertyMappings);
            }
            finally
            {
                TestHelpers.ExecuteNonQuery(connectionString, "DROP TABLE " + tableName);
            }
        }
Пример #2
0
        public void Fails_On_MisMatch_Column_Manual_Map()
        {
            string connectionString = TestHelpers.ConnectionString;
            string tableName        = BulkWriter.AutoDiscover.TableName <MyTestClass>(false);

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[Name] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            var mapping = MapBuilder
                          .MapAllProperties <MyTestClass>()
                          .MapProperty(x => x.Name, x => x.ToColumnName("MisMatchColumn"));

            IEnumerable <BulkWriter.PropertyMapping> propertyMappings = ((BulkWriter.MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            try
            {
                Assert.Throws <InvalidOperationException>(() => AutoDiscover.Mappings(connectionString, tableName, propertyMappings));
            }
            finally
            {
                TestHelpers.ExecuteNonQuery(connectionString, "DROP TABLE " + tableName);
            }
        }
Пример #3
0
        public void Maps_Only_Appropriate_Properties()
        {
            const string connectionString = "Data Source=(local);Initial Catalog=BulkWriterTest;Integrated Security=SSPI";
            string       tableName        = AutoDiscover.TableName <MyTestClass>(false);

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[Name] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            IMapBuilderContext <MyTestClass> mapping = MapBuilder
                                                       .MapAllProperties <MyTestClass>()
                                                       .MapProperty(x => x.Id, x => x.DoNotMap()); // Do not map this property

            IEnumerable <PropertyMapping> propertyMappings = ((MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            AutoDiscover.Mappings(connectionString, tableName, propertyMappings);

            TestHelpers.ExecuteNonQuery(connectionString, "DROP TABLE " + tableName);

            foreach (PropertyMapping propertyMapping in propertyMappings)
            {
                if (propertyMapping.ShouldMap)
                {
                    for (int i = 0; i < MappingDestination.PropertyIndexCount; i++)
                    {
                        Assert.IsTrue(propertyMapping.Destination.IsPropertySet((MappingProperty)i));
                    }
                }
            }
        }
Пример #4
0
        public void Discovers_Quoted_Table_Name()
        {
            string tableName = AutoDiscover.TableName <MyTestClass>(true);

            StringAssert.StartsWith(tableName, "[");
            StringAssert.EndsWith(tableName, "]");
        }
Пример #5
0
        public NSPIAdapter(ITestSite site)
        {
            this.site = site;
            this.originalServerName = Common.GetConfigurationPropertyValue("SutComputerName", this.site);
            this.userName           = Common.GetConfigurationPropertyValue("AdminUserName", this.site);
            this.domainName         = Common.GetConfigurationPropertyValue("Domain", this.site);
            this.password           = Common.GetConfigurationPropertyValue("AdminUserPassword", this.site);
            this.waitTime           = int.Parse(Common.GetConfigurationPropertyValue("WaitTime", this.site));
            this.maxRetryCount      = uint.Parse(Common.GetConfigurationPropertyValue("RetryCount", this.site));
            string requestURL = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.site);

            requestURL              = Regex.Replace(requestURL, @"\[ServerName\]", this.originalServerName, RegexOptions.IgnoreCase);
            this.transport          = Common.GetConfigurationPropertyValue("TransportSeq", this.site).ToLower(System.Globalization.CultureInfo.CurrentCulture);
            AdapterHelper.Transport = this.transport;
            if (this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp")
            {
                this.InitializeRPC();
                this.nspiRpcAdapter = new NspiRpcAdapter(this.site, this.rpcBinding, this.contextHandle, this.waitTime, this.maxRetryCount);
            }
            else
            {
                AdapterHelper.SessionContextCookies = new CookieCollection();
                this.autoDiscoverProperties         = AutoDiscover.GetAutoDiscoverProperties(this.site, this.originalServerName, this.userName, this.domainName, requestURL, this.transport);
                this.site.Assert.IsNotNull(this.autoDiscoverProperties.AddressBookUrl, @"The auto discover process should return the URL to be used to connect with a NSPI server through MAPI over HTTP successfully.");
                this.nspiMapiHttpAdapter = new NspiMapiHttpAdapter(this.site, this.userName, this.password, this.domainName, this.autoDiscoverProperties.AddressBookUrl);
            }
        }
        /// <summary>
        /// Get the mailbox server endpoint URI and the address book server endpoint URI by Autodiscover.
        /// </summary>
        private void GetEndpointUrl()
        {
            string originalServerName = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
            string transportSequence  = Common.GetConfigurationPropertyValue("TransportSeq", this.Site);
            string requestURL         = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.Site);

            requestURL = Regex.Replace(requestURL, @"\[ServerName\]", originalServerName, RegexOptions.IgnoreCase);

            AutoDiscoverProperties autoDiscoverProperties = AutoDiscover.GetAutoDiscoverProperties(this.Site, originalServerName, this.userName, this.domainName, requestURL, transportSequence.ToLower());

            this.mailStoreUrl   = autoDiscoverProperties.PrivateMailStoreUrl;
            this.addressBookUrl = autoDiscoverProperties.AddressBookUrl;
        }
Пример #7
0
        private async Task Connect()
        {
            await Log("Connecting to device...");

            arduino = await AutoDiscover.ConnectDevice();

            if (arduino == null)
            {
                await Log("Device not found.");
            }

            arduino.DeviceReady            += Arduino_DeviceReady;
            arduino.DeviceConnectionFailed += Arduino_DeviceConnectionFailed;
            arduino.DeviceConnectionLost   += Arduino_DeviceConnectionLost;
            arduino.DigitalPinUpdated      += Arduino_DigitalPinUpdated;
            arduino.AnalogPinUpdated       += Arduino_AnalogPinUpdated;
        }
        public void Initialize_Test()
        {
            this.enumerable = new[] { new MyTestClass() };

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[Name] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            var mapping          = MapBuilder.MapAllProperties <MyTestClass>();
            var propertyMappings = ((MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            AutoDiscover.Mappings(connectionString, tableName, propertyMappings);

            this.dataReader = new EnumerableDataReader <MyTestClass>(enumerable, propertyMappings);
            dataReader.Read();
        }
 /// <summary>
 /// Initializes the current adapter instance associated with a test site.
 /// </summary>
 /// <param name="testSite">The test site instance associated with the current adapter.</param>
 public override void Initialize(ITestSite testSite)
 {
     base.Initialize(testSite);
     testSite.DefaultProtocolDocShortName = "MS-OXNSPI";
     Common.MergeConfiguration(testSite);
     AdapterHelper.Site = testSite;
     if (bool.Parse(Common.GetConfigurationPropertyValue("MS-OXNSPI_Supported", this.Site)))
     {
         this.nspiRpcAdapter      = null;
         this.nspiMapiHttpAdapter = null;
         this.originalServerName  = Common.GetConfigurationPropertyValue("SutComputerName", this.Site);
         this.userName            = Common.GetConfigurationPropertyValue("User1Name", this.Site);
         this.Site.Assume.IsNotNull(this.userName, "The User1Name field in the ptfconfig file should not be null.");
         this.Site.Assume.IsNotNull(Common.GetConfigurationPropertyValue("User2Name", this.Site), "The User2Name field in the ptfconfig file should not be null.");
         this.Site.Assume.IsNotNull(Common.GetConfigurationPropertyValue("User3Name", this.Site), "The User3Name field in the ptfconfig file should not be null.");
         this.domainName = Common.GetConfigurationPropertyValue("Domain", this.Site);
         this.password   = Common.GetConfigurationPropertyValue("User1Password", this.Site);
         string publicFolderMailbox = Common.GetConfigurationPropertyValue("PublicFolderMailbox", this.Site);
         string requestURL          = Common.GetConfigurationPropertyValue("AutoDiscoverUrlFormat", this.Site);
         requestURL     = Regex.Replace(requestURL, @"\[ServerName\]", this.originalServerName, RegexOptions.IgnoreCase);
         this.transport = Common.GetConfigurationPropertyValue("TransportSeq", this.Site).ToLower(System.Globalization.CultureInfo.CurrentCulture);
         this.Site.Assert.IsTrue(this.transport == "mapi_http" || this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp", @"The TransportSeq field in the ptfconfig file must be set to one of the following three values: mapi_http, ncacn_http and ncacn_ip_tcp.");
         this.waitTime           = Convert.ToInt32(Common.GetConfigurationPropertyValue("WaitTime", testSite));
         this.maxRetryCount      = Convert.ToUInt32(Common.GetConfigurationPropertyValue("RetryCount", testSite));
         AdapterHelper.Transport = this.transport;
         if (this.transport == "ncacn_http" || this.transport == "ncacn_ip_tcp")
         {
             this.InitializeRPC();
             this.nspiRpcAdapter = new NspiRpcAdapter(this.Site, this.rpcBinding, this.contextHandle, this.waitTime, this.maxRetryCount);
         }
         else
         {
             AdapterHelper.SessionContextCookies = new CookieCollection();
             this.autoDiscoverProperties         = AutoDiscover.GetAutoDiscoverProperties(this.Site, this.originalServerName, this.userName, this.domainName, requestURL, this.transport, publicFolderMailbox);
             this.Site.Assert.IsNotNull(this.autoDiscoverProperties.AddressBookUrl, @"The auto discover process should return the URL to be used to connect with a NSPI server through MAPI over HTTP successfully.");
             this.nspiMapiHttpAdapter = new NspiMapiHttpAdapter(this.Site, this.userName, this.password, this.domainName, this.autoDiscoverProperties.AddressBookUrl);
         }
     }
 }
Пример #10
0
        public void Can_Find_Column_Manual_Map()
        {
            const string connectionString = "Data Source=(local);Initial Catalog=BulkWriterTest;Integrated Security=SSPI";
            const string tableName        = "TempTestTable";

            TestHelpers.ExecuteNonQuery(connectionString,
                                        "CREATE TABLE [dbo].[" + tableName + "](" +
                                        "[Id] [int] IDENTITY(1,1) NOT NULL," +
                                        "[ManualColumnName] [nvarchar](50) NULL," +
                                        "CONSTRAINT [PK_" + tableName + "] PRIMARY KEY CLUSTERED ([Id] ASC)" +
                                        ")");

            IMapBuilderContext <MyTestClass> mapping = MapBuilder
                                                       .MapAllProperties <MyTestClass>()
                                                       .DestinationTable(tableName)
                                                       .MapProperty(x => x.Name, x => x.ToColumnName("ManualColumnName"));

            IEnumerable <PropertyMapping> propertyMappings = ((MapBuilderContext <MyTestClass>)mapping).GetPropertyMappings();

            AutoDiscover.Mappings(connectionString, tableName, propertyMappings);

            TestHelpers.ExecuteNonQuery(connectionString, "DROP TABLE " + tableName);

            foreach (PropertyMapping propertyMapping in propertyMappings)
            {
                Assert.IsTrue(propertyMapping.ShouldMap);

                if (propertyMapping.ShouldMap)
                {
                    for (int i = 0; i < MappingDestination.PropertyIndexCount; i++)
                    {
                        Assert.IsTrue(propertyMapping.Destination.IsPropertySet((MappingProperty)i));
                    }
                }
            }
        }
Пример #11
0
        private async void Connect()
        {
            _arduino = await AutoDiscover.ConnectDevice();

            _arduino.DeviceReady += Arduino_DeviceReady;
        }
Пример #12
0
 public void TestMethod1()
 {
     arduino              = AutoDiscover.ConnectDevice().Result;
     arduino.DeviceReady += OnDeviceReady;
 }