<commit_before>//
//  Thali CordovaPlugin
//  VirtualSocketTests.swift
//
//  Copyright (C) Microsoft. All rights reserved.
//  Licensed under the MIT license.
//  See LICENSE.txt file in the project root for full license information.
//

import MultipeerConnectivity
@testable import ThaliCore
import XCTest

class VirtualSocketTests: XCTestCase {

    // MARK: - State
    var mcPeerID: MCPeerID!
    var mcSessionMock: MCSessionMock!
    var nonTCPSession: Session!

    let streamReceivedTimeout: NSTimeInterval = 5.0
    let virtualSocketOpenTimeout: NSTimeInterval = 5.0
    let virtualSocketCloseTimeout: NSTimeInterval = 5.0

    // MARK: - Setup
    override func setUp() {
        mcPeerID = MCPeerID(displayName: String.random(length: 5))
        mcSessionMock = MCSessionMock(peer: MCPeerID(displayName: String.random(length: 5)))
        nonTCPSession = Session(session: mcSessionMock,
                                identifier: mcPeerID,
                                connected: {},
                                notConnected: {})
    }

    // MARK: - Tests
    func testVirtualSocketCreatedWithClosedState() {
        // Given
        do {
            let ouputStream = try nonTCPSession.startOutputStream(with: "test")

            let emptyData = NSData(bytes: nil, length: 0)
            let inputStream = NSInputStream(data: emptyData)
<commit_msg>Improving setUp() and tearDown() methods in VirtualSocketTests.swift.<commit_after>//
//  Thali CordovaPlugin
//  VirtualSocketTests.swift
//
//  Copyright (C) Microsoft. All rights reserved.
//  Licensed under the MIT license.
//  See LICENSE.txt file in the project root for full license information.
//

import MultipeerConnectivity
@testable import ThaliCore
import XCTest

class VirtualSocketTests: XCTestCase {

    // MARK: - State
    var mcPeerID: MCPeerID!
    var mcSessionMock: MCSessionMock!
    var nonTCPSession: Session!

    let streamReceivedTimeout: NSTimeInterval = 5.0
    let virtualSocketOpenTimeout: NSTimeInterval = 5.0
    let virtualSocketCloseTimeout: NSTimeInterval = 5.0

    // MARK: - Setup & Teardown
    override func setUp() {
        super.setUp()
        mcPeerID = MCPeerID(displayName: String.random(length: 5))
        mcSessionMock = MCSessionMock(peer: MCPeerID(displayName: String.random(length: 5)))
        nonTCPSession = Session(session: mcSessionMock,
                                identifier: mcPeerID,
                                connected: {},
                                notConnected: {})
    }

    override func tearDown() {
        mcPeerID = nil
        mcSessionMock = nil
        nonTCPSession = nil
        super.tearDown()
    }

    // MARK: - Tests
    func testVirtualSocketCreatedWithClosedState() {
        // Given
        do {
            let ouputStream = try nonTCPSession.startOutputStream(with: "test")

            let emptyData = NSData(bytes: nil, length: 0)
            let inputStream = NSInputStream(data: emptyData)

{'fraction_non_alphanumeric': 0.08532079274437353, 'fraction_numerical': 0.006046355391333557, 'mean_word_length': 2.376417233560091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4743558', 'n_tokens_mistral': 874, 'n_tokens_neox': 827, 'n_words': 220}