WriteConfigurationNotifications() public method

public WriteConfigurationNotifications ( IEnumerable notifications ) : void
notifications IEnumerable
return void
 public void ResultLogJsonWriter_CannotWriteConfigurationNotificationsTwice()
 {
     using (var str = new StringWriter())
         using (var json = new JsonTextWriter(str))
             using (var uut = new ResultLogJsonWriter(json))
             {
                 uut.WriteTool(DefaultTool);
                 uut.WriteConfigurationNotifications(s_notifications);
                 Assert.Throws <InvalidOperationException>(() => uut.WriteConfigurationNotifications(s_notifications));
             }
 }
 public void ResultLogJsonWriter_CannotWriteConfigurationNotificationsTwice()
 {
     using (var str = new StringWriter())
         using (var json = new JsonTextWriter(str))
             using (var uut = new ResultLogJsonWriter(json))
             {
                 uut.WriteTool(DefaultTool);
                 uut.WriteConfigurationNotifications(s_notifications);
                 uut.WriteConfigurationNotifications(s_notifications);
             }
 }
Exemplo n.º 3
0
        public void Dispose()
        {
            // Disposing the json writer closes the stream but the textwriter
            // still needs to be disposed or closed to write the results
            if (_issueLogJsonWriter != null)
            {
                _issueLogJsonWriter.CloseResults();

                if (_run != null && _run.ConfigurationNotifications != null)
                {
                    _issueLogJsonWriter.WriteConfigurationNotifications(_run.ConfigurationNotifications);
                }

                if (_run != null && _run.ToolNotifications != null)
                {
                    _issueLogJsonWriter.WriteToolNotifications(_run.ToolNotifications);
                }

                if (_run != null &&
                    _run.Invocation != null &&
                    _run.Invocation.StartTime != new DateTime())
                {
                    _run.Invocation.EndTime = DateTime.UtcNow;
                }

                // Note: we write out the backing rules
                // to prevent the property accessor from populating
                // this data with an empty collection.
                if (_rules != null)
                {
                    _issueLogJsonWriter.WriteRules(_rules);
                }

                if (_run != null && _run.Files != null)
                {
                    _issueLogJsonWriter.WriteFiles(_run.Files);
                }

                if (_run != null && _run.Invocation != null)
                {
                    _issueLogJsonWriter.WriteInvocation(invocation: _run.Invocation);
                }

                _issueLogJsonWriter.Dispose();
            }

            if (_textWriter != null)
            {
                _textWriter.Dispose();
            }

            if (_jsonTextWriter == null)
            {
                _jsonTextWriter.Close();
            }

            GC.SuppressFinalize(this);
        }
 public void ResultLogJsonWriter_CannotWriteConfigurationNotificationsTwice()
 {
     using (var str = new StringWriter())
     using (var json = new JsonTextWriter(str))
     using (var uut = new ResultLogJsonWriter(json))
     {
         uut.WriteTool(DefaultTool);
         uut.WriteConfigurationNotifications(s_notifications);
         uut.WriteConfigurationNotifications(s_notifications);
     }
 }