title: URLSession test case
body: <p>I have a user authentication test case that registers user and user is saved in a json file. The whole project is about test and I cannot seem to understand how to go about it.</p>
  
  <p>There is a NetworkService.swift file which handles all test functions but a url was not supplied to call register.</p>
  
  <p><strong>NetworkService.swift</strong></p>
  
  <pre><code>class NetworkService: NSObject {
  
      private let session: URLSession
  
      init(session: URLSession) {
          self.session = session
      }
  
      //token for requests
      var authToken: String?
  
  
      //MARK: Singleton
  
      static var sharedService: NetworkService = NetworkService(session: URLSessionMock())
  
  
      //MARK: Requests
  
      func registerUserWith(login: String?, password: String?, success: @escaping (Data)-&gt;(), failure: @escaping (Error?) -&gt; ()) {
  
          //register user method, use self.session
      }
  
      func getAllEvents(success: @escaping (Data)-&gt;(), failure: @escaping (Error?) -&gt; ()) {
  
          //get all events method, use self.session
      }
  
      func subscribeOnEvent(eventUUID: Int, success: @escaping (Data)-&gt;(), failure: @escaping (Error?) -&gt; ()) {
  
          //subscribe method, use self.session
      }
  
      func unsubscribeFromEvent(eventUUID: Int, success: @escaping (Data)-&gt;(), failure: @escaping (Error?) -&gt; ()) {
  
          //unsubscribe method, use self.session
      }
  }
  </code></pre>
  
  <p>This is a test case </p>
  
  <pre><code>func testUserRegistrationMethod() {
          let expectation: XCTestExpectation = self.expectation(description: "user registration")
  
          let login: String = "testUser"
          let password: String = "pass"
  
          NetworkService.sharedService.registerUserWith(login: login, password: password, success: { (responseData) in
              expectation.fulfill()
              XCTAssertNotNil(responseData, "Data is nil")
  
              do {
                  let json = try JSONSerialization.jsonObject(with: responseData, options:[]) as! [String : Any?]
                  let authToken: String = json["authToken"] as! String
  
                  XCTAssertNotNil(authToken, "AuthToken is nil")
  
              } catch let error {
                  print(error)
              }
          }) { (error) in
              expectation.fulfill()
              XCTFail((error?.localizedDescription)!)
          }
  
          waitForExpectations(timeout: 4) { (error) in
              if error != nil {
                  print(error!)
              }
          }
      }
  </code></pre>
  
  <p>You are working on the application for Conferences. A user of such application should be able to register on this application and interact with it on browsing the available events, be able to subscribe and unsubscribe from the current conference.</p>
  
  <p>Implement a network service that is used to interact with the server.</p>
  
  <p><strong>Problem Statement</strong></p>
  
  <p>You have to implement the following methods:</p>
  
  <ul>
  <li>The function registers users with a login and a password. In case of a successful registration, it returns the token in a success block. In case of an error, it calls a failure block.
  <code>
  func registerUserWith(login: String?, password: String?, success: @escaping (Data)-&gt;(), failure: @escaping (Error?) -&gt; ())
  </code></li>
  </ul>
  
  <p>I am not supplied with a url and do not know if this is a complete question</p>