Ejemplo n.º 1
0
        public void Stop()
        {
            if (Mode == RecordedTestMode.Record)
            {
                var directory = Path.GetDirectoryName(_sessionFile);
                Directory.CreateDirectory(directory);

                using FileStream fileStream = File.Create(_sessionFile);
                var utf8JsonWriter = new Utf8JsonWriter(fileStream, new JsonWriterOptions()
                {
                    Indented = true
                });
                _session.Sanitize(_sanitizer);
                _session.Serialize(utf8JsonWriter);
                utf8JsonWriter.Flush();
            }
        }
Ejemplo n.º 2
0
        public void Dispose(bool save)
        {
            if (Mode == RecordedTestMode.Record && save)
            {
                var directory = Path.GetDirectoryName(_sessionFile);
                Directory.CreateDirectory(directory);

                _session.Sanitize(_sanitizer);
                if (_session.IsEquivalent(_previousSession, _matcher))
                {
                    return;
                }

                using FileStream fileStream = File.Create(_sessionFile);
                var utf8JsonWriter = new Utf8JsonWriter(fileStream, new JsonWriterOptions()
                {
                    Indented = true
                });
                _session.Serialize(utf8JsonWriter);
                utf8JsonWriter.Flush();
            }
        }