public int WriteUserOptions(IStream pOptionsStream, string pszKey)
        {
            if (pszKey == SettingsKey)
            {
                try
                {
                    using (var pStream = new DataStreamFromComStream(pOptionsStream))
                        if (pStream != null && pStream.CanWrite)
                        {
                            using (var ms = new MemoryStream())
                            {
                                var strValue = JsonConvert.SerializeObject(SettingsStore.Instance.MsSqlDatabaseConnectionSettings);
                                var data     = Encoding.ASCII.GetBytes(strValue);
                                pStream.Write(data, 0, data.Length);
                                pStream.Flush();
                            }
                        }
                }
                catch (Exception ex)
                {
                    // TODO: log exception
                }
            }

            return(VSConstants.S_OK);
        }
Beispiel #2
0
        public void Write_DoesNotThrowCountZeroOrLess(int bufferSize, int index, int count)
        {
            // The mock should never be called in outlier cases
            var comStreamMock = new Mock <Ole32.IStream>(MockBehavior.Strict);
            var dataStream    = new DataStreamFromComStream(comStreamMock.Object);

            dataStream.Write(new byte[bufferSize], index, count);
        }
Beispiel #3
0
        public void Write_ThrowsInvalidCount(int bufferSize, int index, int count)
        {
            // The mock should never be called in outlier cases
            var comStreamMock = new Mock <Ole32.IStream>(MockBehavior.Strict);
            var dataStream    = new DataStreamFromComStream(comStreamMock.Object);

            Assert.Throws <IOException>(() => dataStream.Write(new byte[bufferSize], index, count));
        }