示例#1
0
        public void WriteToTable()
        {
            var configuration = new DataStoreConfiguration();
            configuration.ConnectionString = _connectionString;
            configuration.Columns = new List<DataStoreColumn>
            {
                new DataStoreColumn { Name = "First Name", Source = "People" },
                new DataStoreColumn { Name = "Last Name", Source = "People" },
                new DataStoreColumn { Name = "Age", Source = "People" }
            };

            var store = new SqlDataStore(configuration);
            store.Write("John", "Doe", "23");
            store.Write("Jane", "Doe", "21");

            var memoryStore = new MemoryDataStore(configuration);
            memoryStore.Write("John", "Doe", "23");
            memoryStore.Write("Jane", "Doe", "21");

            var actual = store.Read().ToList();
            var expected = memoryStore.Read().ToList();

            TestHelper.AreEqual(expected, actual);
        }
示例#2
0
        public void ReadFromTable()
        {
            var configuration = new DataStoreConfiguration();
            configuration.ConnectionString = _connectionString;
            configuration.Columns = new List<DataStoreColumn>
            {
                new DataStoreColumn { Name = "First Name", Source = "People" },
                new DataStoreColumn { Name = "Last Name", Source = "People" },
                new DataStoreColumn { Name = "Age", Source = "People" }
            };

            RunSql("INSERT INTO [dbo].[People] ([First Name],[Last Name],[Age]) VALUES ('John', 'Doe', 23)");
            RunSql("INSERT INTO [dbo].[People] ([First Name],[Last Name],[Age]) VALUES ('Jane', 'Doe', 21)");

            var store = new SqlDataStore(configuration);
            var actual = store.Read().ToList();

            var memoryStore = new MemoryDataStore(configuration);
            memoryStore.Write("John", "Doe", "23");
            memoryStore.Write("Jane", "Doe", "21");
            var expected = memoryStore.Read().ToList();

            TestHelper.AreEqual(expected, actual);
        }