<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Estuite.Domain;

namespace Estuite
{
    public class SessionFactory : ICreateSessions
    {
        private readonly IProvideUtcDateTime _dateTime;
        private readonly ISerializeEvents _events;

        public SessionFactory(IProvideUtcDateTime dateTime, ISerializeEvents events)
        {
            _dateTime = dateTime;
            _events = events;
        }

        public Session Create(StreamId streamId, SessionId sessionId, IEnumerable<Event> events)
        {
            var created = _dateTime.Now;
            var records = events.Select(x => CreateEventRecord(x, sessionId, created)).ToArray();
            return new Session(streamId, sessionId, created, records);
        }

        private EventRecord CreateEventRecord(Event @event, SessionId sessionId, DateTime created)
        {
            var eventSerialized = _events.Serialize(@event.Body);
            return new EventRecord
            {
                SessionId = sessionId,
                Version = @event.Version,
                Created = created,
                Type = eventSerialized.Type,
                Payload = eventSerialized.Payload
            };
        }
    }
}<commit_msg>argument guards added<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using Estuite.Domain;

namespace Estuite
{
    public class SessionFactory : ICreateSessions
    {
        private readonly IProvideUtcDateTime _dateTime;
        private readonly ISerializeEvents _events;

        public SessionFactory(IProvideUtcDateTime dateTime, ISerializeEvents events)
        {
            _dateTime = dateTime;
            _events = events;
        }

        public Session Create(StreamId streamId, SessionId sessionId, IEnumerable<Event> events)
        {
            if (streamId == null) throw new ArgumentNullException(nameof(streamId));
            if (sessionId == null) throw new ArgumentNullException(nameof(sessionId));
            if (events == null) throw new ArgumentNullException(nameof(events));
            var created = _dateTime.Now;
            var records = events.Select(x => CreateEventRecord(x, sessionId, created)).ToArray();
            return new Session(streamId, sessionId, created, records);
        }

        private EventRecord CreateEventRecord(Event @event, SessionId sessionId, DateTime created)
        {
            var eventSerialized = _events.Serialize(@event.Body);
            return new EventRecord
            {
                SessionId = sessionId,
                Version = @event.Version,
                Created = created,
                Type = eventSerialized.Type,
                Payload = eventSerialized.Payload
            };
        }
    }
}
{'fraction_non_alphanumeric': 0.07334525939177101, 'fraction_numerical': 0.0, 'mean_word_length': 2.213793103448276, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2726956', 'n_tokens_mistral': 692, 'n_tokens_neox': 676, 'n_words': 176}